[pypy-svn] r66853 - in pypy/branch/parser-compiler/pypy/tool/pytest: . test
benjamin at codespeak.net
benjamin at codespeak.net
Sun Aug 16 04:21:56 CEST 2009
Author: benjamin
Date: Sun Aug 16 04:21:53 2009
New Revision: 66853
Added:
pypy/branch/parser-compiler/pypy/tool/pytest/test/test_appsupport.py
Modified:
pypy/branch/parser-compiler/pypy/tool/pytest/appsupport.py
Log:
fix exc_info() for exception that aren't caught in except blocks
Modified: pypy/branch/parser-compiler/pypy/tool/pytest/appsupport.py
==============================================================================
--- pypy/branch/parser-compiler/pypy/tool/pytest/appsupport.py (original)
+++ pypy/branch/parser-compiler/pypy/tool/pytest/appsupport.py Sun Aug 16 04:21:53 2009
@@ -182,6 +182,18 @@
space.newtuple([w_BuiltinAssertionError]),
w_dict)
+def _exc_info(space, err):
+ """Hack the fact that exc_info() isn't set until a app except
+ block catches it."""
+ err.normalize_exception(space)
+ frame = space.getexecutioncontext().framestack.top()
+ old = frame.last_exception
+ frame.last_exception = err
+ try:
+ return space.sys.call("exc_info")
+ finally:
+ frame.last_exception = old
+
def pypyraises(space, w_ExpectedException, w_expr, __args__):
"""A built-in function providing the equivalent of py.test.raises()."""
args_w, kwds_w = __args__.unpack()
@@ -201,14 +213,14 @@
space.exec_(source.compile(), frame.w_globals, w_locals)
except OperationError, e:
if e.match(space, w_ExpectedException):
- return space.sys.call('exc_info')
+ return _exc_info(space, e)
raise
else:
try:
space.call_args(w_expr, __args__)
except OperationError, e:
if e.match(space, w_ExpectedException):
- return space.sys.call('exc_info')
+ return _exc_info(space, e)
raise
raise OperationError(space.w_AssertionError,
space.wrap("DID NOT RAISE"))
Added: pypy/branch/parser-compiler/pypy/tool/pytest/test/test_appsupport.py
==============================================================================
--- (empty file)
+++ pypy/branch/parser-compiler/pypy/tool/pytest/test/test_appsupport.py Sun Aug 16 04:21:53 2009
@@ -0,0 +1,6 @@
+
+
+def app_test_raises():
+ info = raises(TypeError, id)
+ assert info[0] is TypeError
+ assert isinstance(info[1], TypeError)
More information about the Pypy-commit
mailing list