added failing exception test for generators
authorStefan Behnel <scoder@users.berlios.de>
Sun, 17 Apr 2011 09:45:14 +0000 (11:45 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 17 Apr 2011 09:45:14 +0000 (11:45 +0200)
tests/run/generators_py.py

index ea16659af2f43b1e424e006ed086ce02eee382df..ac364234be9559dc8f5a978e906db47f40a40321 100644 (file)
@@ -155,6 +155,22 @@ def check_throw():
         except ValueError:
             pass
 
+def check_yield_in_except():
+    """
+    >>> import sys
+    >>> orig_exc = sys.exc_info()[0]
+    >>> g = check_yield_in_except()
+    >>> next(g)
+    >>> next(g)
+    >>> orig_exc is sys.exc_info()[0] or sys.exc_info()[0]
+    True
+    """
+    try:
+        yield
+        raise ValueError
+    except ValueError:
+        yield
+
 def test_swap_assignment():
     """
     >>> gen = test_swap_assignment()