[py-svn] r57443 - in py/release/0.9.x/py: code/testing execnet path test test/testing

hpk at codespeak.net hpk at codespeak.net
Mon Aug 18 20:09:21 CEST 2008


Author: hpk
Date: Mon Aug 18 20:09:19 2008
New Revision: 57443

Modified:
   py/release/0.9.x/py/code/testing/test_safe_repr.py
   py/release/0.9.x/py/execnet/rsync.py
   py/release/0.9.x/py/path/common.py
   py/release/0.9.x/py/test/deprecate.py
   py/release/0.9.x/py/test/testing/test_session.py
Log:
porting python2.6 fixes from trunk rev 57440 


Modified: py/release/0.9.x/py/code/testing/test_safe_repr.py
==============================================================================
--- py/release/0.9.x/py/code/testing/test_safe_repr.py	(original)
+++ py/release/0.9.x/py/code/testing/test_safe_repr.py	Mon Aug 18 20:09:19 2008
@@ -24,7 +24,12 @@
     assert 'Exception' in safe_repr._repr(BrokenRepr(BrokenReprException("really broken")))
 
 def test_string_exception():
-    assert 'unknown' in safe_repr._repr(BrokenRepr("string"))
+    if py.std.sys.version_info < (2,6):
+        assert 'unknown' in safe_repr._repr(BrokenRepr("string"))
+    else:
+        assert 'TypeError' in safe_repr._repr(BrokenRepr("string"))
+        
+
 
 def test_big_repr():
     assert len(safe_repr._repr(range(1000))) <= \

Modified: py/release/0.9.x/py/execnet/rsync.py
==============================================================================
--- py/release/0.9.x/py/execnet/rsync.py	(original)
+++ py/release/0.9.x/py/execnet/rsync.py	Mon Aug 18 20:09:19 2008
@@ -1,6 +1,9 @@
-import py, os, stat, md5
+import py, os, stat
 from Queue import Queue
-
+try:
+    from hashlib import md5
+except ImportError:
+    from md5 import md5
 
 class RSync(object):
     """ This class allows to send a directory structure (recursively)

Modified: py/release/0.9.x/py/path/common.py
==============================================================================
--- py/release/0.9.x/py/path/common.py	(original)
+++ py/release/0.9.x/py/path/common.py	Mon Aug 18 20:09:19 2008
@@ -431,7 +431,7 @@
 
 old_import_hook = None
 
-def custom_import_hook(name, glob=None, loc=None, fromlist=None):
+def custom_import_hook(name, glob=None, loc=None, fromlist=None, extra=None, level=None):
     __tracebackhide__ = False 
     __file__ = glob and glob.get('__file__')
     if isinstance(__file__, PathStr):
@@ -457,5 +457,9 @@
                 return modules[0]   # outermost package
     # fall-back
     __tracebackhide__ = True 
-    return old_import_hook(name, glob, loc, fromlist)
+    try:
+        return old_import_hook(name, glob, loc, fromlist, level)
+    except TypeError:
+        return old_import_hook(name, glob, loc, fromlist)
+        
 

Modified: py/release/0.9.x/py/test/deprecate.py
==============================================================================
--- py/release/0.9.x/py/test/deprecate.py	(original)
+++ py/release/0.9.x/py/test/deprecate.py	Mon Aug 18 20:09:19 2008
@@ -4,15 +4,26 @@
     """ assert that calling func(*args, **kwargs)
         triggers a DeprecationWarning. 
     """ 
+    warningmodule = py.std.warnings
     l = []
-    oldwarn = py.std.warnings.warn_explicit
+    oldwarn_explicit = getattr(warningmodule, 'warn_explicit')
     def warn_explicit(*args, **kwargs): 
         l.append(args) 
+        oldwarn_explicit(*args, **kwargs)
+    oldwarn = getattr(warningmodule, 'warn')
+    def warn(*args, **kwargs): 
+        l.append(args) 
         oldwarn(*args, **kwargs)
         
-    py.magic.patch(py.std.warnings, 'warn_explicit', warn_explicit)
+    warningmodule.warn_explicit = warn_explicit
+    warningmodule.warn = warn
     try:
-        _ = func(*args, **kwargs)
+        ret = func(*args, **kwargs)
     finally:
-        py.magic.revert(py.std.warnings, 'warn_explicit')
-    assert l
+        warningmodule.warn_explicit = warn_explicit
+        warningmodule.warn = warn
+    if not l:
+        print warningmodule
+        raise AssertionError("%r did not produce DeprecationWarning" %(func,))
+    return ret
+

Modified: py/release/0.9.x/py/test/testing/test_session.py
==============================================================================
--- py/release/0.9.x/py/test/testing/test_session.py	(original)
+++ py/release/0.9.x/py/test/testing/test_session.py	Mon Aug 18 20:09:19 2008
@@ -289,7 +289,8 @@
         l = session.getitemoutcomepairs(Failed)
         assert len(l) == 2
         assert out.find("""[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""") != -1 #'
-        assert out.find("[unknown exception raised in repr()]") != -1
+        assert (out.find("[unknown exception raised in repr()]") != -1 or 
+                out.find("TypeError") != -1)
 
     def test_E_on_correct_line(self):
         o = tmpdir.ensure('E_on_correct_line', dir=1)



More information about the pytest-commit mailing list