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
This commit is contained in:
parent
f2c8a837af
commit
fa6d5bd15b
|
@ -95,7 +95,10 @@ class monkeypatch:
|
|||
self._setattr[:] = []
|
||||
for dictionary, name, value in self._setitem:
|
||||
if value is notset:
|
||||
dictionary.pop(name, None)
|
||||
try:
|
||||
del dictionary[name]
|
||||
except KeyError:
|
||||
pass # was already deleted, so we have the desired state
|
||||
else:
|
||||
dictionary[name] = value
|
||||
self._setitem[:] = []
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -436,8 +436,7 @@ def test_pytest_cmdline_main(testdir):
|
|||
py.test.cmdline.main([__file__])
|
||||
""")
|
||||
import subprocess
|
||||
popen = subprocess.Popen([sys.executable, str(p)],
|
||||
stdout=subprocess.PIPE, env={})
|
||||
popen = subprocess.Popen([sys.executable, str(p)], stdout=subprocess.PIPE)
|
||||
s = popen.stdout.read()
|
||||
ret = popen.wait()
|
||||
assert ret == 0
|
||||
|
|
Loading…
Reference in New Issue