[py-svn] r51563 - in py/branch/event/py/test2: . testing
hpk at codespeak.net
hpk at codespeak.net
Sun Feb 17 19:39:34 CET 2008
Author: hpk
Date: Sun Feb 17 19:39:33 2008
New Revision: 51563
Modified:
py/branch/event/py/test2/outcome.py
py/branch/event/py/test2/testing/test_outcome.py
Log:
enhance py.test2.deprecated call a bit.
Modified: py/branch/event/py/test2/outcome.py
==============================================================================
--- py/branch/event/py/test2/outcome.py (original)
+++ py/branch/event/py/test2/outcome.py Sun Feb 17 19:39:33 2008
@@ -103,7 +103,9 @@
py.magic.patch(py.std.warnings, 'warn_explicit', warn_explicit)
try:
- _ = func(*args, **kwargs)
+ ret = func(*args, **kwargs)
finally:
py.magic.revert(py.std.warnings, 'warn_explicit')
- assert l
+ if not l:
+ raise AssertionError("%r did not produce DeprecationWarning" %(func,))
+ return ret
Modified: py/branch/event/py/test2/testing/test_outcome.py
==============================================================================
--- py/branch/event/py/test2/testing/test_outcome.py (original)
+++ py/branch/event/py/test2/testing/test_outcome.py Sun Feb 17 19:39:33 2008
@@ -23,6 +23,7 @@
def dep(i):
if i == 0:
py.std.warnings.warn("is deprecated", DeprecationWarning)
+ return 42
reg = {}
def dep_explicit(i):
@@ -31,12 +32,17 @@
filename="hello", lineno=3)
def test_deprecated_call_raises():
- py.test2.raises(AssertionError,
+ excinfo = py.test2.raises(AssertionError,
"py.test2.deprecated_call(dep, 3)")
+ assert str(excinfo).find("did not produce") != -1
def test_deprecated_call():
py.test2.deprecated_call(dep, 0)
+def test_deprecated_call_ret():
+ ret = py.test2.deprecated_call(dep, 0)
+ assert ret == 42
+
def test_deprecated_call_preserves():
r = py.std.warnings.onceregistry.copy()
f = py.std.warnings.filters[:]
More information about the pytest-commit
mailing list