@@ -716,16 +716,16 @@ async def test_doubleincrement(doubleincrement):
716
716
def test_blockon_in_hook (testdir , cmd_opts , request ):
717
717
skip_if_reactor_not (request , "default" )
718
718
conftest_file = """
719
- import pytest_twisted as pt
719
+ import pytest_twisted
720
720
from twisted.internet import reactor, defer
721
721
722
722
def pytest_configure(config):
723
- pt .init_default_reactor()
723
+ pytest_twisted .init_default_reactor()
724
724
d1, d2 = defer.Deferred(), defer.Deferred()
725
725
reactor.callLater(0.01, d1.callback, 1)
726
726
reactor.callLater(0.02, d2.callback, 1)
727
- pt .blockon(d1)
728
- pt .blockon(d2)
727
+ pytest_twisted .blockon(d1)
728
+ pytest_twisted .blockon(d2)
729
729
"""
730
730
testdir .makeconftest (conftest_file )
731
731
test_file = """
@@ -761,18 +761,18 @@ def test_succeed():
761
761
def test_blockon_in_hook_with_qt5reactor (testdir , cmd_opts , request ):
762
762
skip_if_reactor_not (request , "qt5reactor" )
763
763
conftest_file = """
764
- import pytest_twisted as pt
764
+ import pytest_twisted
765
765
import pytestqt
766
766
from twisted.internet import defer
767
767
768
768
def pytest_configure(config):
769
- pt .init_qt5_reactor()
769
+ pytest_twisted .init_qt5_reactor()
770
770
d = defer.Deferred()
771
771
772
772
from twisted.internet import reactor
773
773
774
774
reactor.callLater(0.01, d.callback, 1)
775
- pt .blockon(d)
775
+ pytest_twisted .blockon(d)
776
776
"""
777
777
testdir .makeconftest (conftest_file )
778
778
test_file = """
@@ -863,20 +863,20 @@ def test_blockon_in_hook_with_asyncio(testdir, cmd_opts, request):
863
863
skip_if_reactor_not (request , "asyncio" )
864
864
conftest_file = """
865
865
import pytest
866
- import pytest_twisted as pt
866
+ import pytest_twisted
867
867
from twisted.internet import defer
868
868
869
869
@pytest.hookimpl(tryfirst=True)
870
870
def pytest_configure(config):
871
- pt ._use_asyncio_selector_if_required(config=config)
871
+ pytest_twisted ._use_asyncio_selector_if_required(config=config)
872
872
873
- pt .init_asyncio_reactor()
873
+ pytest_twisted .init_asyncio_reactor()
874
874
d = defer.Deferred()
875
875
876
876
from twisted.internet import reactor
877
877
878
878
reactor.callLater(0.01, d.callback, 1)
879
- pt .blockon(d)
879
+ pytest_twisted .blockon(d)
880
880
"""
881
881
testdir .makeconftest (conftest_file )
882
882
test_file = """
@@ -1047,3 +1047,25 @@ async def test_self_isinstance(self, foo):
1047
1047
testdir .makepyfile (test_file )
1048
1048
rr = testdir .run (* cmd_opts , timeout = timeout )
1049
1049
assert_outcomes (rr , {"passed" : 1 })
1050
+
1051
+
1052
+ def test_import_pytest_twisted_in_conftest_py_not_a_problem (testdir , cmd_opts ):
1053
+ conftest_file = """
1054
+ import pytest
1055
+ import pytest_twisted
1056
+
1057
+
1058
+ @pytest.hookimpl(tryfirst=True)
1059
+ def pytest_configure(config):
1060
+ pytest_twisted._use_asyncio_selector_if_required(config=config)
1061
+ """
1062
+ testdir .makeconftest (conftest_file )
1063
+ test_file = """
1064
+ import pytest_twisted
1065
+
1066
+ def test_succeed():
1067
+ pass
1068
+ """
1069
+ testdir .makepyfile (test_file )
1070
+ rr = testdir .run (* cmd_opts , timeout = timeout )
1071
+ assert_outcomes (rr , {"passed" : 1 })
0 commit comments