Py<2.5 test fix
[cython.git] / tests / run / with_statement_module_level_T536.pyx
index daf38d3d5121796184929800bbe3752842661ab9..122f440672169a813bb271ccf74607d22971e0c7 100644 (file)
@@ -1,18 +1,34 @@
+# ticket: 536
 
 __doc__ = """
 >>> inner_result
 ['ENTER']
->>> result
+>>> result  # doctest: +ELLIPSIS
+['ENTER', "EXIT (<...ValueError...>,...ValueError..., <traceback object at ...)"]
+
+>>> inner_result_no_exc
+['ENTER']
+>>> result_no_exc
 ['ENTER', 'EXIT (None, None, None)']
 """
 
-result = []
-
 class ContextManager(object):
+    def __init__(self, result):
+        self.result = result
     def __enter__(self):
-        result.append("ENTER")
+        self.result.append("ENTER")
     def __exit__(self, *values):
-        result.append("EXIT %r" % (values,))
+        self.result.append("EXIT %r" % (values,))
+        return True
+
+result_no_exc = []
+
+with ContextManager(result_no_exc) as c:
+    inner_result_no_exc = result_no_exc[:]
+
+result = []
 
-with ContextManager() as c:
+with ContextManager(result) as c:
     inner_result = result[:]
+    raise ValueError('TEST')
+