[svn r57440] various fixes for python2.6
--HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									fc3721259f
								
							
						
					
					
						commit
						a20731b111
					
				|  | @ -24,7 +24,12 @@ def test_broken_exception(): | ||||||
|     assert 'Exception' in safe_repr._repr(BrokenRepr(BrokenReprException("really broken"))) |     assert 'Exception' in safe_repr._repr(BrokenRepr(BrokenReprException("really broken"))) | ||||||
| 
 | 
 | ||||||
| def test_string_exception(): | 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(): | def test_big_repr(): | ||||||
|     assert len(safe_repr._repr(range(1000))) <= \ |     assert len(safe_repr._repr(range(1000))) <= \ | ||||||
|  |  | ||||||
|  | @ -1,6 +1,9 @@ | ||||||
| import py, os, stat, md5 | import py, os, stat | ||||||
| from Queue import Queue | from Queue import Queue | ||||||
| 
 | try: | ||||||
|  |     from hashlib import md5 | ||||||
|  | except ImportError: | ||||||
|  |     from md5 import md5 | ||||||
| 
 | 
 | ||||||
| class RSync(object): | class RSync(object): | ||||||
|     """ This class allows to send a directory structure (recursively) |     """ This class allows to send a directory structure (recursively) | ||||||
|  |  | ||||||
|  | @ -431,7 +431,7 @@ def relativeimport(p, name, parent=None): | ||||||
| 
 | 
 | ||||||
| old_import_hook = None | 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  |     __tracebackhide__ = False  | ||||||
|     __file__ = glob and glob.get('__file__') |     __file__ = glob and glob.get('__file__') | ||||||
|     if isinstance(__file__, PathStr): |     if isinstance(__file__, PathStr): | ||||||
|  | @ -457,5 +457,9 @@ def custom_import_hook(name, glob=None, loc=None, fromlist=None): | ||||||
|                 return modules[0]   # outermost package |                 return modules[0]   # outermost package | ||||||
|     # fall-back |     # fall-back | ||||||
|     __tracebackhide__ = True  |     __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) | ||||||
|  |          | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -99,18 +99,26 @@ def deprecated_call(func, *args, **kwargs): | ||||||
|     """ assert that calling func(*args, **kwargs) |     """ assert that calling func(*args, **kwargs) | ||||||
|         triggers a DeprecationWarning.  |         triggers a DeprecationWarning.  | ||||||
|     """  |     """  | ||||||
|  |     warningmodule = py.std.warnings | ||||||
|     l = [] |     l = [] | ||||||
|     oldwarn = py.std.warnings.warn_explicit |     oldwarn_explicit = getattr(warningmodule, 'warn_explicit') | ||||||
|     def warn_explicit(*args, **kwargs):  |     def warn_explicit(*args, **kwargs):  | ||||||
|  |         l.append(args)  | ||||||
|  |         oldwarn_explicit(*args, **kwargs) | ||||||
|  |     oldwarn = getattr(warningmodule, 'warn') | ||||||
|  |     def warn(*args, **kwargs):  | ||||||
|         l.append(args)  |         l.append(args)  | ||||||
|         oldwarn(*args, **kwargs) |         oldwarn(*args, **kwargs) | ||||||
|          |          | ||||||
|     py.magic.patch(py.std.warnings, 'warn_explicit', warn_explicit) |     warningmodule.warn_explicit = warn_explicit | ||||||
|  |     warningmodule.warn = warn | ||||||
|     try: |     try: | ||||||
|         ret = func(*args, **kwargs) |         ret = func(*args, **kwargs) | ||||||
|     finally: |     finally: | ||||||
|         py.magic.revert(py.std.warnings, 'warn_explicit') |         warningmodule.warn_explicit = warn_explicit | ||||||
|  |         warningmodule.warn = warn | ||||||
|     if not l: |     if not l: | ||||||
|  |         print warningmodule | ||||||
|         raise AssertionError("%r did not produce DeprecationWarning" %(func,)) |         raise AssertionError("%r did not produce DeprecationWarning" %(func,)) | ||||||
|     return ret |     return ret | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -187,7 +187,8 @@ class SessionTests(suptest.InlineCollection): | ||||||
|         out = failed[0].outcome.longrepr.reprcrash.message |         out = failed[0].outcome.longrepr.reprcrash.message | ||||||
|         assert out.find("""[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""") != -1 #' |         assert out.find("""[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""") != -1 #' | ||||||
|         out = failed[1].outcome.longrepr.reprcrash.message |         out = failed[1].outcome.longrepr.reprcrash.message | ||||||
|         assert out.find("[unknown exception raised in repr()]") != -1 |         assert (out.find("[unknown exception raised in repr()]") != -1  or | ||||||
|  |                 out.find("TypeError") != -1) | ||||||
| 
 | 
 | ||||||
| class TestNewSession(SessionTests): | class TestNewSession(SessionTests): | ||||||
|     def test_pdb_run(self): |     def test_pdb_run(self): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue