[pypy-commit] pypy py3k: - allow to pass string to raises when we run tests with -A

antocuni noreply at buildbot.pypy.org
Mon Feb 13 18:27:03 CET 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: py3k
Changeset: r52415:689ab9a80822
Date: 2012-02-10 18:03 +0100
http://bitbucket.org/pypy/pypy/changeset/689ab9a80822/

Log:	- allow to pass string to raises when we run tests with -A

	- split test_reraise into multiple tests (most of them failing)

diff --git a/pypy/conftest.py b/pypy/conftest.py
--- a/pypy/conftest.py
+++ b/pypy/conftest.py
@@ -206,7 +206,10 @@
         raise SystemExit(0)
     def raises(exc, func, *args, **kwargs):
         try:
-            func(*args, **kwargs)
+            if isinstance(func, str):
+                exec("if 1:\\n" + func)
+            else:
+                func(*args, **kwargs)
         except exc:
             pass
         else:
diff --git a/pypy/interpreter/test/test_raise.py b/pypy/interpreter/test/test_raise.py
--- a/pypy/interpreter/test/test_raise.py
+++ b/pypy/interpreter/test/test_raise.py
@@ -65,9 +65,7 @@
         assert exc_val is exc_val2
         assert exc_tb is exc_tb2.tb_next
 
-    def test_reraise(self):
-        # some collection of funny code
-        import sys
+    def test_reraise_1(self):
         raises(ValueError, """
             import sys
             try:
@@ -79,6 +77,8 @@
                     assert sys.exc_info()[0] is ValueError
                     raise
         """)
+
+    def test_reraise_2(self):
         raises(ValueError, """
             def foo():
                 import sys
@@ -92,6 +92,8 @@
                 finally:
                     foo()
         """)
+
+    def test_reraise_3(self):
         raises(IndexError, """
             def spam():
                 import sys
@@ -109,6 +111,8 @@
                     spam()
         """)
 
+    def test_reraise_4(self):
+        import sys
         try:
             raise ValueError
         except:
@@ -118,6 +122,7 @@
                 ok = sys.exc_info()[0] is KeyError
         assert ok
 
+    def test_reraise_5(self):
         raises(IndexError, """
             import sys
             try:


More information about the pypy-commit mailing list