robustify monkeypatch

This commit is contained in:
holger krekel
2011-12-16 22:41:23 +00:00
parent f5f8695587
commit 40187ec9bb
5 changed files with 23 additions and 4 deletions

View File

@@ -59,6 +59,20 @@ def test_setitem():
monkeypatch.undo()
assert d['x'] == 5
def test_setitem_deleted_meanwhile():
d = {}
monkeypatch = MonkeyPatch()
monkeypatch.setitem(d, 'x', 2)
del d['x']
monkeypatch.undo()
assert not d
def test_setenv_deleted_meanwhile():
monkeypatch = MonkeyPatch()
monkeypatch.setenv('XYZ123', 'hello')
monkeypatch.undo()
assert 'XYZ123' not in os.environ
def test_delitem():
d = {'x': 1}
monkeypatch = MonkeyPatch()