From a8b36a0b5456b94ad9f0a105dfd7229ec4ef09eb Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Mon, 19 Jun 2017 02:53:57 -0700 Subject: [PATCH 1/2] Formatting fixups --- trio/tests/test_util.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/trio/tests/test_util.py b/trio/tests/test_util.py index 309e6ac81f..d2685591a0 100644 --- a/trio/tests/test_util.py +++ b/trio/tests/test_util.py @@ -79,8 +79,8 @@ async def manager_issue29692(): assert excinfo.value.args[0] == 'issue29692:Chained' assert isinstance(excinfo.value.__cause__, ZeroDivisionError) - # This is a little funky because of implementation details in async_generator - # It can all go away once we stop supporting Python3.5 + # This is a little funky because of implementation details in + # async_generator It can all go away once we stop supporting Python3.5 with pytest.raises(RuntimeError) as excinfo: async with manager_issue29692(): exc = StopIteration('issue29692:Unchained') @@ -112,7 +112,8 @@ async def manager_issue29692_2(): nativeasyncgenerators = False -@pytest.mark.skipif(not nativeasyncgenerators, reason="Python < 3.6 doesn't have native async generators") +@pytest.mark.skipif(not nativeasyncgenerators, + reason="Python < 3.6 doesn't have native async generators") async def test_native_contextmanager_do_not_unchain_non_stopiteration_exceptions(): with pytest.raises(RuntimeError) as excinfo: From 670dfa936ec78d27f172670cf7aecf408c810d5f Mon Sep 17 00:00:00 2001 From: "Nathaniel J. Smith" Date: Mon, 19 Jun 2017 02:54:16 -0700 Subject: [PATCH 2/2] Test StopIteration can pass through an async_generator async context manager --- trio/tests/test_util.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/trio/tests/test_util.py b/trio/tests/test_util.py index d2685591a0..7d47474e02 100644 --- a/trio/tests/test_util.py +++ b/trio/tests/test_util.py @@ -96,6 +96,14 @@ async def manager_issue29692(): assert excinfo.value.args[0] == 'issue29692:Unchained' assert excinfo.value.__cause__ is None + @acontextmanager + @async_generator + async def noop_async_context_manager(): + await yield_() + + with pytest.raises(StopIteration): + async with noop_async_context_manager(): + raise StopIteration # Native async generators are only available from Python 3.6 and onwards nativeasyncgenerators = True