…lines 1–9 unchanged (9 lines)
10 set_asyncio_event_loop,
11)
12from tests.utils.decorators import coroutine_test
13
14
15class TestAsyncio:
16 @pytest.mark.requires_reactor # needs a reactor
17 def test_is_asyncio_reactor_installed(self, reactor_pytest: str) -> None:
18 # the result should depend only on the pytest --reactor argument
19 assert is_asyncio_reactor_installed() == (reactor_pytest == "asyncio")
20
21 @pytest.mark.requires_reactor # installs a reactor
22 def test_install_asyncio_reactor(self):
23 from twisted.internet import reactor as original_reactor
24
25 with warnings.catch_warnings(record=True) as w:
26 install_reactor(_asyncio_reactor_path)
27 assert len(w) == 0, [str(warning) for warning in w]
28 from twisted.internet import reactor # pylint: disable=reimported
29
30 assert original_reactor == reactor
31
32 @pytest.mark.requires_reactor # installs a reactor
33 @pytest.mark.only_asyncio
34 @coroutine_test
35 async def test_set_asyncio_event_loop(self):
36 install_reactor(_asyncio_reactor_path)
37 assert set_asyncio_event_loop(None) is asyncio.get_running_loop()
38