1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/changeset/52c436be8d63/
changeset:   52c436be8d63
user:        hpk42
date:        2011-12-16 23:41:23
summary:     robustify monkeypatch
affected #:  5 files

diff -r a69c4555285c888ec506db401a68c1100e1fe6bc -r 
52c436be8d635a7f49f741b24f0bdc03d1de0036 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+Changes between 2.2.1 and 2.2.2.dev
+----------------------------------------
+
+- make monkeypatch more robust against intermediate dict/env deletions
+
 Changes between 2.2.0 and 2.2.1
 ----------------------------------------
 


diff -r a69c4555285c888ec506db401a68c1100e1fe6bc -r 
52c436be8d635a7f49f741b24f0bdc03d1de0036 _pytest/__init__.py
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
 #
-__version__ = '2.2.1'
+__version__ = '2.2.2.dev1'


diff -r a69c4555285c888ec506db401a68c1100e1fe6bc -r 
52c436be8d635a7f49f741b24f0bdc03d1de0036 _pytest/monkeypatch.py
--- a/_pytest/monkeypatch.py
+++ b/_pytest/monkeypatch.py
@@ -95,7 +95,7 @@
         self._setattr[:] = []
         for dictionary, name, value in self._setitem:
             if value is notset:
-                del dictionary[name]
+                dictionary.pop(name, None)
             else:
                 dictionary[name] = value
         self._setitem[:] = []


diff -r a69c4555285c888ec506db401a68c1100e1fe6bc -r 
52c436be8d635a7f49f741b24f0bdc03d1de0036 setup.py
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@
         name='pytest',
         description='py.test: simple powerful testing with Python',
         long_description = long_description,
-        version='2.2.1',
+        version='2.2.2.dev1',
         url='http://pytest.org',
         license='MIT license',
         platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'],
@@ -70,4 +70,4 @@
     return {'console_scripts': l}
 
 if __name__ == '__main__':
-    main()
+    main()
\ No newline at end of file


diff -r a69c4555285c888ec506db401a68c1100e1fe6bc -r 
52c436be8d635a7f49f741b24f0bdc03d1de0036 testing/test_monkeypatch.py
--- a/testing/test_monkeypatch.py
+++ b/testing/test_monkeypatch.py
@@ -59,6 +59,20 @@
     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()

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to