Skip to content

Commit f70013d

Browse files
author
ajohns
committed
-added test for environ in execute_command
1 parent 1da4887 commit f70013d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/rez/tests/test_context.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ def test_execute_command(self):
5858
stdout = stdout.strip()
5959
self.assertEqual(stdout, "Hello Rez World!")
6060

61+
def test_execute_command_environ(self):
62+
"""Test that execute_command properly sets environ dict."""
63+
parent_environ = {"BIGLY": "covfefe"}
64+
r = ResolvedContext(["hello_world"])
65+
66+
pycode = ("import os; "
67+
"print os.getenv(\"BIGLY\"); "
68+
"print os.getenv(\"OH_HAI_WORLD\")")
69+
70+
args = ["python", "-c", pycode]
71+
72+
p = r.execute_command(args, parent_environ=parent_environ,
73+
stdout=subprocess.PIPE)
74+
stdout, _ = p.communicate()
75+
stdout = stdout.strip()
76+
parts = [x.strip() for x in stdout.split('\n')]
77+
78+
self.assertEqual(parts, ["covfefe", "hello"])
79+
6180
def test_serialize(self):
6281
"""Test save/load of context."""
6382
# save

0 commit comments

Comments
 (0)