[pypy-svn] r67264 - in pypy/trunk/pypy: . tool/pytest/test

benjamin at codespeak.net benjamin at codespeak.net
Thu Aug 27 23:41:15 CEST 2009


Author: benjamin
Date: Thu Aug 27 23:41:14 2009
New Revision: 67264

Modified:
   pypy/trunk/pypy/conftest.py
   pypy/trunk/pypy/tool/pytest/test/test_appsupport.py
Log:
fix app tests using raises with a string instead of a callable argument

and I thought just using sys._getframe() was bad enough... :(


Modified: pypy/trunk/pypy/conftest.py
==============================================================================
--- pypy/trunk/pypy/conftest.py	(original)
+++ pypy/trunk/pypy/conftest.py	Thu Aug 27 23:41:14 2009
@@ -189,10 +189,17 @@
 #
 #
 
-def _pytest_raises_wrapper(*args, **kwargs):
+def _pytest_raises_wrapper(*__args, **__kwargs):
     """Emulate the API of appsupport.pypyraises."""
     __tracebackhide__ = True
-    return py.test.raises(*args, **kwargs)._excinfo
+    # Horrible, nasty, terrible, hideous, ugly hack to help another one.
+    if len(__args) == 2 and isinstance(__args[1], str):
+        me = sys._getframe()
+        them = sys._getframe(1)
+        me.f_globals.update(them.f_globals)
+        me.f_locals.update(them.f_locals)
+        del me, them
+    return py.test.raises(*__args, **__kwargs)._excinfo
 
 def ensure_pytest_builtin_helpers(helpers='skip'.split()):
     """ hack (py.test.) raises and skip into builtins, needed

Modified: pypy/trunk/pypy/tool/pytest/test/test_appsupport.py
==============================================================================
--- pypy/trunk/pypy/tool/pytest/test/test_appsupport.py	(original)
+++ pypy/trunk/pypy/tool/pytest/test/test_appsupport.py	Thu Aug 27 23:41:14 2009
@@ -4,3 +4,6 @@
     info = raises(TypeError, id)
     assert info[0] is TypeError
     assert isinstance(info[1], TypeError)
+
+    x = 43
+    raises(ZeroDivisionError, "x/0")



More information about the Pypy-commit mailing list