summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-26 18:01:16 -0500
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-12-26 18:19:07 -0500
commitc61e17931243d014fda59321e972076d16a263a0 (patch)
treee4e53b234520cb989e029af1217cbe84868f8316
parentfe4fc0b5b15c3c21d2503cbcefce1ae958091ad1 (diff)
downloadbuildstream-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.py7
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