Skip to content

Commit

Permalink
Fix: ensure tools.environment_append doesn't raise trying to unset va…
Browse files Browse the repository at this point in the history
…riables (#4324)

* - ensure tools.environment_append doesn't raise trying to unset variables

Signed-off-by: SSE4 <tomskside@gmail.com>

* Update env.py
  • Loading branch information
SSE4 authored and lasote committed Jan 17, 2019
1 parent 261e658 commit 0e3d03b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conans/client/tools/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def environment_append(env_vars):
old_env = dict(os.environ)
os.environ.update(env_vars)
for var in unset_vars:
os.environ.pop(var)
os.environ.pop(var, None)
try:
yield
finally:
Expand Down
6 changes: 6 additions & 0 deletions conans/test/unittests/client/tools/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ def test_environment_append_unsetting_all_variables(self):
'env_var2': 'value2'}),\
env.environment_append({'env_var1': None}):
self.assertNotIn('env_var1', os.environ)

def test_environment_append_unsetting_non_existing_variables(self):
with mock.patch.dict('os.environ',
{'env_var2': 'value2'}),\
env.environment_append({'env_var1': None}):
self.assertNotIn('env_var1', os.environ)

0 comments on commit 0e3d03b

Please sign in to comment.