@@ -912,3 +912,87 @@ def test_second(foo):
912
912
testdir .makepyfile (test_file )
913
913
rr = testdir .run (* cmd_opts , timeout = timeout )
914
914
assert_outcomes (rr , {"passed" : 2 })
915
+
916
+
917
+ def test_inlinecallbacks_method_with_fixture_gets_self (testdir , cmd_opts ):
918
+ test_file = """
919
+ import pytest
920
+ import pytest_twisted
921
+ from twisted.internet import defer
922
+
923
+ @pytest.fixture
924
+ def foo():
925
+ return 37
926
+
927
+ class TestClass:
928
+ @pytest_twisted.inlineCallbacks
929
+ def test_self_isinstance(self, foo):
930
+ d = defer.succeed(None)
931
+ yield d
932
+ assert isinstance(self, TestClass)
933
+ """
934
+ testdir .makepyfile (test_file )
935
+ rr = testdir .run (* cmd_opts )
936
+ assert_outcomes (rr , {"passed" : 1 })
937
+
938
+
939
+ def test_inlinecallbacks_method_with_fixture_gets_fixture (testdir , cmd_opts ):
940
+ test_file = """
941
+ import pytest
942
+ import pytest_twisted
943
+ from twisted.internet import defer
944
+
945
+ @pytest.fixture
946
+ def foo():
947
+ return 37
948
+
949
+ class TestClass:
950
+ @pytest_twisted.inlineCallbacks
951
+ def test_self_isinstance(self, foo):
952
+ d = defer.succeed(None)
953
+ yield d
954
+ assert foo == 37
955
+ """
956
+ testdir .makepyfile (test_file )
957
+ rr = testdir .run (* cmd_opts , timeout = timeout )
958
+ assert_outcomes (rr , {"passed" : 1 })
959
+
960
+
961
+ @skip_if_no_async_await ()
962
+ def test_ensuredeferred_method_with_fixture_gets_self (testdir , cmd_opts ):
963
+ test_file = """
964
+ import pytest
965
+ import pytest_twisted
966
+
967
+ @pytest.fixture
968
+ def foo():
969
+ return 37
970
+
971
+ class TestClass:
972
+ @pytest_twisted.ensureDeferred
973
+ async def test_self_isinstance(self, foo):
974
+ assert isinstance(self, TestClass)
975
+ """
976
+ testdir .makepyfile (test_file )
977
+ rr = testdir .run (* cmd_opts , timeout = timeout )
978
+ assert_outcomes (rr , {"passed" : 1 })
979
+
980
+
981
+ @skip_if_no_async_await ()
982
+ def test_ensuredeferred_method_with_fixture_gets_fixture (testdir , cmd_opts ):
983
+ test_file = """
984
+ import pytest
985
+ import pytest_twisted
986
+
987
+ @pytest.fixture
988
+ def foo():
989
+ return 37
990
+
991
+ class TestClass:
992
+ @pytest_twisted.ensureDeferred
993
+ async def test_self_isinstance(self, foo):
994
+ assert foo == 37
995
+ """
996
+ testdir .makepyfile (test_file )
997
+ rr = testdir .run (* cmd_opts , timeout = timeout )
998
+ assert_outcomes (rr , {"passed" : 1 })
0 commit comments