Skip to content

Commit

Permalink
cleanup environment changes reliably
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Dec 15, 2017
1 parent df957b4 commit df23d4d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/unit_tests/test_environment_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def test_appends_windows(self):
self.assertEqual(['set foo=bar'], code)

def test_generate_environment_script(self):
old_environ = os.environ
try:
fake_environ = os.environ.copy()
fake_environ['FOO'] = '/bar'
Expand All @@ -80,5 +81,6 @@ def test_generate_environment_script(self):
self.assertTrue('export BAR="/bar"' in result, result)
self.assertEqual('#!/usr/bin/env sh', result[0])
finally:
os.environ = old_environ
catkin.environment_cache.os.environ = os.environ
shutil.rmtree(rootdir)
2 changes: 2 additions & 0 deletions test/unit_tests/test_workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
class WorkspaceTest(unittest.TestCase):

def test_get_workspaces(self):
old_environ = os.environ
try:
root_dir = tempfile.mkdtemp()
ws1 = os.path.join(root_dir, 'ws1')
Expand All @@ -38,6 +39,7 @@ def test_get_workspaces(self):
self.assertEqual([ws2, ws1], get_workspaces())
finally:
shutil.rmtree(root_dir)
os.environ = old_environ
catkin.workspace.os.environ = os.environ

def test_get_source_paths(self):
Expand Down

0 comments on commit df23d4d

Please sign in to comment.