[pypy-svn] r42761 - in pypy/dist/pypy/tool: pytest test

afa at codespeak.net afa at codespeak.net
Sun May 6 22:55:41 CEST 2007


Author: afa
Date: Sun May  6 22:55:40 2007
New Revision: 42761

Modified:
   pypy/dist/pypy/tool/pytest/appsupport.py
   pypy/dist/pypy/tool/test/test_error.py
   pypy/dist/pypy/tool/test/test_pytestsupport.py
Log:
Better support in tests, when a applevel function calls an interp-level function
which raises a (faked) builtin exception.

Just trying to understand why test_select keeps failing on scottdial.com


Modified: pypy/dist/pypy/tool/pytest/appsupport.py
==============================================================================
--- pypy/dist/pypy/tool/pytest/appsupport.py	(original)
+++ pypy/dist/pypy/tool/pytest/appsupport.py	Sun May  6 22:55:40 2007
@@ -65,7 +65,7 @@
     def __init__(self, space, operr):
         self.space = space
         self.operr = operr
-        self.typename = operr.w_type.name
+        self.typename = operr.w_type.getname(space, "?")
         self.traceback = AppTraceback(space, self.operr.application_traceback)
         debug_excs = getattr(operr, 'debug_excs', [])
         if debug_excs:

Modified: pypy/dist/pypy/tool/test/test_error.py
==============================================================================
--- pypy/dist/pypy/tool/test/test_error.py	(original)
+++ pypy/dist/pypy/tool/test/test_error.py	Sun May  6 22:55:40 2007
@@ -1,5 +1,5 @@
 
-""" Tests some error handilng routines
+""" Tests some error handling routines
 """
 
 from pypy.translator.translator import TranslationContext

Modified: pypy/dist/pypy/tool/test/test_pytestsupport.py
==============================================================================
--- pypy/dist/pypy/tool/test/test_pytestsupport.py	(original)
+++ pypy/dist/pypy/tool/test/test_pytestsupport.py	Sun May  6 22:55:40 2007
@@ -69,6 +69,22 @@
     assert not appex.errisinstance(A) 
 
 
+def test_fakedexception(space):
+    from cPickle import PicklingError
+    def raise_error():
+        raise PicklingError("SomeMessage")
+    space.setitem(space.builtin.w_dict, space.wrap('raise_error'),
+                  space.wrap(raise_error))
+    
+    try:
+        space.appexec([], "(): raise_error()")
+    except OperationError, e:
+        appex = AppExceptionInfo(space, e)
+    else:
+        py.test.fail("did not raise!")
+    assert "PicklingError" in appex.exconly()
+    assert "SomeMessage" in appex.exconly()
+
 class AppTestWithWrappedInterplevelAttributes: 
     def setup_class(cls): 
         space = cls.space



More information about the Pypy-commit mailing list