[pypy-commit] pypy py3k: add a failing test from test_contextlib: we lack WHY_SILENCED

pjenvey pypy.commits at gmail.com
Tue Apr 26 19:09:00 EDT 2016


Author: Philip Jenvey <pjenvey at underboss.org>
Branch: py3k
Changeset: r83932:d815525436b8
Date: 2016-04-26 16:07 -0700
http://bitbucket.org/pypy/pypy/changeset/d815525436b8/

Log:	add a failing test from test_contextlib: we lack WHY_SILENCED

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
@@ -438,6 +438,30 @@
         else:
             fail('No exception raised')
 
+    def test_context_with_suppressed(self):
+        # XXX: requires with statement's WHY_SILENCED
+        class RaiseExc:
+            def __init__(self, exc):
+                self.exc = exc
+            def __enter__(self):
+                return self
+            def __exit__(self, *exc_details):
+                raise self.exc
+
+        class SuppressExc:
+            def __enter__(self):
+                return self
+            def __exit__(self, *exc_details):
+                return True
+
+        try:
+            with RaiseExc(IndexError):
+                with SuppressExc():
+                    with RaiseExc(ValueError):
+                        1/0
+        except IndexError as exc:
+            assert exc.__context__ is None
+
 
 class AppTestTraceback:
 


More information about the pypy-commit mailing list