Author: Armin Rigo <ar...@tunes.org> Branch: py3.5-corowrapper Changeset: r87211:a9db1cd81bce Date: 2016-09-18 22:06 +0200 http://bitbucket.org/pypy/pypy/changeset/a9db1cd81bce/
Log: Two tests, one passing diff --git a/pypy/interpreter/test/test_coroutine.py b/pypy/interpreter/test/test_coroutine.py --- a/pypy/interpreter/test/test_coroutine.py +++ b/pypy/interpreter/test/test_coroutine.py @@ -141,3 +141,22 @@ else: assert False, "should have raised" """ + + def test_async_with_exception_context(self): """ + class CM: + async def __aenter__(self): + pass + async def __aexit__(self, *e): + 1/0 + async def f(): + async with CM(): + raise ValueError + c = f() + try: + c.send(None) + except ZeroDivisionError as e: + assert e.__context__ is not None + assert isinstance(e.__context__, ValueError) + else: + assert False, "should have raised" + """ 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 @@ -460,6 +460,23 @@ 1/0 except IndexError as exc: assert exc.__context__ is None + else: + assert False, "should have raised" + + def test_with_exception_context(self): + class Ctx: + def __enter__(self): + pass + def __exit__(self, *e): + 1/0 + try: + with Ctx(): + raise ValueError + except ZeroDivisionError as e: + assert e.__context__ is not None + assert isinstance(e.__context__, ValueError) + else: + assert False, "should have raised" class AppTestTraceback: _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit