[svn r57440] various fixes for python2.6

--HG--
branch : trunk
This commit is contained in:
hpk
2008-08-18 19:33:31 +02:00
parent fc3721259f
commit a20731b111
5 changed files with 30 additions and 9 deletions

View File

@@ -99,18 +99,26 @@ def deprecated_call(func, *args, **kwargs):
""" 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:
ret = func(*args, **kwargs)
finally:
py.magic.revert(py.std.warnings, 'warn_explicit')
warningmodule.warn_explicit = warn_explicit
warningmodule.warn = warn
if not l:
print warningmodule
raise AssertionError("%r did not produce DeprecationWarning" %(func,))
return ret

View File

@@ -187,7 +187,8 @@ class SessionTests(suptest.InlineCollection):
out = failed[0].outcome.longrepr.reprcrash.message
assert out.find("""[Exception("Ha Ha fooled you, I'm a broken repr().") raised in repr()]""") != -1 #'
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):
def test_pdb_run(self):