Skip to content

Commit 3f03860

Browse files
testgres.os_ops 2.0.1 is used (master) (#324)
New test TestOsOpsCommon::test_exec_command_with_exec_env__2 is added, too.
1 parent de884d4 commit 3f03860

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dependencies = [
5454
"six>=1.9.0",
5555
"psutil",
5656
"packaging",
57-
"testgres.os_ops>=2.0.0,<3.0.0",
57+
"testgres.os_ops @ git+https://github.com/postgrespro/testgres.os_ops.git@2.0.1",
5858
]
5959

6060
[project.urls]

tests/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ pytest
33
pytest-xdist
44
psycopg2
55
six
6-
testgres.os_ops>=2.0.0,<3.0.0
6+
git+https://github.com/postgrespro/testgres.os_ops.git@2.0.1

tests/test_os_ops_common.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,44 @@ def test_exec_command_with_exec_env(self, os_ops: OsOperations):
130130
assert type(response) == bytes # noqa: E721
131131
assert response == b'\n'
132132

133+
def test_exec_command_with_exec_env__2(self, os_ops: OsOperations):
134+
assert isinstance(os_ops, OsOperations)
135+
136+
RunConditions.skip_if_windows()
137+
138+
C_ENV_NAME = "TESTGRES_TEST__EXEC_ENV_20250414"
139+
140+
tmp_file_content = "echo ${{{}}}".format(C_ENV_NAME)
141+
142+
logging.info("content is [{}]".format(tmp_file_content))
143+
144+
tmp_file = os_ops.mkstemp()
145+
assert type(tmp_file) == str # noqa: E721
146+
assert tmp_file != ""
147+
148+
logging.info("file is [{}]".format(tmp_file))
149+
assert os_ops.path_exists(tmp_file)
150+
151+
os_ops.write(tmp_file, tmp_file_content)
152+
153+
cmd = ["sh", tmp_file]
154+
155+
exec_env = {C_ENV_NAME: "Hello!"}
156+
157+
response = os_ops.exec_command(cmd, exec_env=exec_env)
158+
assert response is not None
159+
assert type(response) == bytes # noqa: E721
160+
assert response == b'Hello!\n'
161+
162+
response = os_ops.exec_command(cmd)
163+
assert response is not None
164+
assert type(response) == bytes # noqa: E721
165+
assert response == b'\n'
166+
167+
os_ops.remove_file(tmp_file)
168+
assert not os_ops.path_exists(tmp_file)
169+
return
170+
133171
def test_exec_command_with_cwd(self, os_ops: OsOperations):
134172
assert isinstance(os_ops, OsOperations)
135173

0 commit comments

Comments
 (0)