From e5e3dc7a90685a56747a2d4c3c770d74d573c497 Mon Sep 17 00:00:00 2001 From: simonfagerholm Date: Wed, 22 Apr 2020 19:18:53 +0200 Subject: [PATCH] Added unittests for issue #154. --- tests/test_simple.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_simple.py b/tests/test_simple.py index 00c07fcb..c8dccaf8 100644 --- a/tests/test_simple.py +++ b/tests/test_simple.py @@ -128,6 +128,29 @@ async def test_asyncio_marker_without_loop(self, remove_loop): assert ret == 'ok' +class TestEventLoopStartedBeforeFixtures: + @pytest.fixture + async def loop(self): + return asyncio.get_event_loop() + + @staticmethod + def foo(): + return 1 + + @pytest.mark.asyncio + async def test_no_event_loop(self, loop): + assert await loop.run_in_executor(None, self.foo) == 1 + + @pytest.mark.asyncio + async def test_event_loop_after_fixture(self, loop, event_loop): + assert await loop.run_in_executor(None, self.foo) == 1 + + @pytest.mark.asyncio + async def test_event_loop_before_fixture(self, event_loop, loop): + assert await loop.run_in_executor(None, self.foo) == 1 + + + @pytest.mark.asyncio async def test_no_warning_on_skip(): pytest.skip("Test a skip error inside asyncio")