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

hpk at codespeak.net hpk at codespeak.net
Sun Jun 6 17:32:24 CEST 2010


Author: hpk
Date: Sun Jun  6 17:32:22 2010
New Revision: 75145

Modified:
   pypy/trunk/pypy/tool/pytest/appsupport.py
   pypy/trunk/pypy/tool/pytest/test/test_appsupport.py
Log:
fix the pypy/py.test customized AppExceptionInfo: 
only try matching "space.w_NAME" exceptions for 
interplevel builtin exceptions


Modified: pypy/trunk/pypy/tool/pytest/appsupport.py
==============================================================================
--- pypy/trunk/pypy/tool/pytest/appsupport.py	(original)
+++ pypy/trunk/pypy/tool/pytest/appsupport.py	Sun Jun  6 17:32:22 2010
@@ -86,11 +86,18 @@
         if debug_excs:
             self._excinfo = debug_excs[0]
 
+    def __repr__(self):
+        return "<AppExceptionInfo %s>" % self.operr.errorstr(self.space)
+
     def exconly(self, tryshort=True):
         return '(application-level) ' + self.operr.errorstr(self.space)
 
     def errisinstance(self, exc): 
         clsname = exc.__name__ 
+        # we can only check for builtin exceptions
+        # as there is no canonical applevel one for custom interplevel ones
+        if exc.__module__ != "exceptions":
+            return False 
         try: 
             w_exc = getattr(self.space, 'w_' + clsname) 
         except KeyboardInterrupt: 

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	Sun Jun  6 17:32:22 2010
@@ -113,6 +113,19 @@
         "*E*application-level*NameError*x*not defined",
     ])
 
+def test_applevel_raise_keyerror(testdir):
+    setpypyconftest(testdir)
+    p = testdir.makepyfile("""
+        def app_test_raises():
+            raise KeyError(42)
+            pass
+    """)
+    result = testdir.runpytest(p, "-s")
+    assert result.ret == 1
+    result.stdout.fnmatch_lines([
+        "*E*application-level*KeyError*42*",
+    ])
+
 def app_test_raises():
     info = raises(TypeError, id)
     assert info.type is TypeError



More information about the Pypy-commit mailing list