Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup environment changes in tests reliably #906

Merged
merged 1 commit into from
Dec 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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