@@ -49,6 +49,19 @@ def format_run_result_output_for_assert(run_result):
4949 )
5050
5151
52+ @pytest .fixture (name = "default_conftest" , autouse = True )
53+ def _default_conftest (testdir ):
54+ testdir .makeconftest (textwrap .dedent ("""
55+ import pytest
56+ import pytest_twisted
57+
58+
59+ @pytest.hookimpl(tryfirst=True)
60+ def pytest_configure(config):
61+ pytest_twisted.use_asyncio_selector_if_required(config=config)
62+ """ ))
63+
64+
5265def skip_if_reactor_not (request , expected_reactor ):
5366 actual_reactor = request .config .getoption ("reactor" , "default" )
5467 if actual_reactor != expected_reactor :
@@ -627,10 +640,14 @@ def main():
627640def test_blockon_in_hook_with_asyncio (testdir , cmd_opts , request ):
628641 skip_if_reactor_not (request , "asyncio" )
629642 conftest_file = """
643+ import pytest
630644 import pytest_twisted as pt
631645 from twisted.internet import defer
632646
647+ @pytest.hookimpl(tryfirst=True)
633648 def pytest_configure(config):
649+ pt.use_asyncio_selector_if_required(config=config)
650+
634651 pt.init_asyncio_reactor()
635652 d = defer.Deferred()
636653
@@ -656,6 +673,14 @@ def test_succeed():
656673def test_wrong_reactor_with_asyncio (testdir , cmd_opts , request ):
657674 skip_if_reactor_not (request , "asyncio" )
658675 conftest_file = """
676+ import pytest
677+ import pytest_twisted
678+
679+
680+ @pytest.hookimpl(tryfirst=True)
681+ def pytest_configure(config):
682+ pytest_twisted.use_asyncio_selector_if_required(config=config)
683+
659684 def pytest_addhooks():
660685 import twisted.internet.default
661686 twisted.internet.default.install()
0 commit comments