diff options
author | holger krekel <holger@merlinux.eu> | 2011-12-28 15:49:13 +0000 |
---|---|---|
committer | holger krekel <holger@merlinux.eu> | 2011-12-28 15:49:13 +0000 |
commit | fa6d5bd15bdc2da99c067168f3b256a52e7e08ab (patch) | |
tree | 550f050867475808dbea04d4a561061b0baca6e4 /testing/test_monkeypatch.py | |
parent | f2c8a837af2b84d66f225edc399a6a72e160cea7 (diff) | |
download | pytest-fa6d5bd15bdc2da99c067168f3b256a52e7e08ab.tar.gz |
work around an apparent python2.4/python2.5 bug with subprocess.Popen,
causing jenkins failures. Apparently "os.environ.popitem(name, None)"
is not the same as::
try:
del os.environ[name]
except KeyError:
pass
Diffstat (limited to 'testing/test_monkeypatch.py')
-rw-r--r-- | testing/test_monkeypatch.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/testing/test_monkeypatch.py b/testing/test_monkeypatch.py index 54c588331..c1abe0743 100644 --- a/testing/test_monkeypatch.py +++ b/testing/test_monkeypatch.py @@ -67,12 +67,20 @@ def test_setitem_deleted_meanwhile(): monkeypatch.undo() assert not d -def test_setenv_deleted_meanwhile(): +@pytest.mark.parametrize("before", [True, False]) +def test_setenv_deleted_meanwhile(before): + key = "qwpeoip123" + if before: + os.environ[key] = "world" monkeypatch = MonkeyPatch() - monkeypatch.setenv('XYZ123', 'hello') - del os.environ['XYZ123'] + monkeypatch.setenv(key, 'hello') + del os.environ[key] monkeypatch.undo() - assert 'XYZ123' not in os.environ + if before: + assert os.environ[key] == "world" + del os.environ[key] + else: + assert key not in os.environ def test_delitem(): d = {'x': 1} |