diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-12-26 18:01:16 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-12-26 18:19:07 -0500 |
commit | c61e17931243d014fda59321e972076d16a263a0 (patch) | |
tree | e4e53b234520cb989e029af1217cbe84868f8316 | |
parent | fe4fc0b5b15c3c21d2503cbcefce1ae958091ad1 (diff) | |
download | buildstream-c61e17931243d014fda59321e972076d16a263a0.tar.gz |
tests/testutils/runcli.py: Fixed broken environment handling
Treat None values in the passed dictionary as keys to be removed
from the environment, this was already happening at restoration time.
-rw-r--r-- | tests/testutils/runcli.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/testutils/runcli.py b/tests/testutils/runcli.py index f94cec8ae..1f6951abe 100644 --- a/tests/testutils/runcli.py +++ b/tests/testutils/runcli.py @@ -529,13 +529,16 @@ def environment(env): old_env = {} for key, value in env.items(): old_env[key] = os.environ.get(key) - os.environ[key] = value + if value is None: + os.environ.pop(key, None) + else: + os.environ[key] = value yield for key, value in old_env.items(): if value is None: - del os.environ[key] + os.environ.pop(key, None) else: os.environ[key] = value |