Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Jean-Christophe Morin <38703886+JeanChristopheMorinPerso@users.noreply.github.com>
Signed-off-by: Nate Cheung <nathan.cheung.451@outlook.com>
  • Loading branch information
nca45 and JeanChristopheMorinPerso authored Jul 17, 2024
1 parent d267a0c commit 6fbc8e3
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/rez/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def test_execute_command(self):
def test_resolved_packages_testing_environ(self):
"""Test resolving packages within a testing environment behaves correctly"""
packages_path = self.data_path("builds", "packages")

# Note how we use testing=True
r = ResolvedContext(["testing_obj"], testing=True, package_paths=[packages_path])
resolvedPackages = [x.qualified_package_name for x in r.resolved_packages]
self.assertEqual(resolvedPackages, ["floob", "testing_obj-1.0.0"])
Expand All @@ -82,20 +84,8 @@ def test_execute_command_testing_environ(self):
"""Test that execute_command properly sets test specific environ dict"""
self.inject_python_repo()
packages_path = self.data_path("builds", "packages")
r = ResolvedContext(["testing_obj", "python"], testing=True, package_paths=[packages_path])
self._test_execute_command_test_environ(r)

def _test_execute_command_test_environ(self, r):
pycode = ("import os; "
"print(os.getenv(\"CAR_IDEA\"));")

args = ["python", "-c", pycode]

p = r.execute_command(args, stdout=subprocess.PIPE)
stdout, _ = p.communicate()
stdout = stdout.strip()
parts = [x.strip() for x in stdout.decode("utf-8").split('\n')]
self.assertEqual(parts, ["STURDY STEERING WHEEL"])
r = ResolvedContext(["testing_obj", "python"], testing=True, package_paths=[packages_path] + self.settings["packages_path"])
self.assertEqual(r.get_environ().get("CAR_IDEA"), "STURDY STEERING WHEEL")

def test_execute_command_environ(self):
"""Test that execute_command properly sets environ dict."""
Expand Down

0 comments on commit 6fbc8e3

Please sign in to comment.