Fix clearing EnvironmentModifications with python2 (#10791)

* Fix clearing EnvironmentModifications with python2

* Add EnvironmentModifications::clear unit test

Use re-assignment rather than del to clear array

* Fix flake issues
This commit is contained in:
Nick Forrington 2019-03-12 20:12:51 -05:00 committed by Adam J. Stewart
parent da28b592fc
commit 6bda37f542
2 changed files with 8 additions and 1 deletions

View File

@ -306,3 +306,10 @@ def test_preserve_environment(prepare_environment_for_tests):
assert 'NOT_SET' not in os.environ
assert os.environ['UNSET_ME'] == 'foo'
assert os.environ['PATH_LIST'] == '/path/second:/path/third'
def test_clear(env):
env.set('A', 'dummy value')
assert len(env) > 0
env.clear()
assert len(env) == 0

View File

@ -353,7 +353,7 @@ def clear(self):
"""
Clears the current list of modifications
"""
self.env_modifications.clear()
self.env_modifications = []
def apply_modifications(self):
"""Applies the modifications and clears the list."""