# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview
# User holger krekel <hol...@merlinux.eu>
# Date 1272043721 -7200
# Node ID 5b46c382846322fa7f1701ab749a960aac2d78fe
# Parent  7d94c647674daa3aa07088c3167254cdd04debc1
this should test and fix the same issue that was committed in
the pypy svn-repo as r72534

--- a/py/_test/outcome.py
+++ b/py/_test/outcome.py
@@ -100,7 +100,7 @@ def raises(ExpectedException, *args, **k
         k = ", ".join(["%s=%r" % x for x in kwargs.items()])
         if k:
             k = ', ' + k
-        expr = '%s(%r%s)' %(func.__name__, args, k)
+        expr = '%s(%r%s)' %(getattr(func, '__name__', func), args, k)
     raise ExceptionFailure(msg="DID NOT RAISE", 
                            expr=args, expected=ExpectedException) 
 

--- a/testing/test_outcome.py
+++ b/testing/test_outcome.py
@@ -15,6 +15,16 @@ class TestRaises:
     def test_raises_function(self):
         py.test.raises(ValueError, int, 'hello')
 
+    def test_raises_callable_no_exception(self):
+        from py._test.outcome import ExceptionFailure
+        class A:
+            def __call__(self):
+                pass
+        try:
+            py.test.raises(ValueError, A())
+        except ExceptionFailure:
+            pass
+
 def test_pytest_exit():
     try:
         py.test.exit("hello")
_______________________________________________
py-svn mailing list
py-svn@codespeak.net
http://codespeak.net/mailman/listinfo/py-svn

Reply via email to