@@ -963,3 +963,87 @@ def test_second(foo):
963
963
testdir .makepyfile (test_file )
964
964
rr = testdir .run (* cmd_opts , timeout = timeout )
965
965
assert_outcomes (rr , {"passed" : 2 })
966
+
967
+
968
+ def test_inlinecallbacks_method_with_fixture_gets_self (testdir , cmd_opts ):
969
+ test_file = """
970
+ import pytest
971
+ import pytest_twisted
972
+ from twisted.internet import defer
973
+
974
+ @pytest.fixture
975
+ def foo():
976
+ return 37
977
+
978
+ class TestClass:
979
+ @pytest_twisted.inlineCallbacks
980
+ def test_self_isinstance(self, foo):
981
+ d = defer.succeed(None)
982
+ yield d
983
+ assert isinstance(self, TestClass)
984
+ """
985
+ testdir .makepyfile (test_file )
986
+ rr = testdir .run (* cmd_opts )
987
+ assert_outcomes (rr , {"passed" : 1 })
988
+
989
+
990
+ def test_inlinecallbacks_method_with_fixture_gets_fixture (testdir , cmd_opts ):
991
+ test_file = """
992
+ import pytest
993
+ import pytest_twisted
994
+ from twisted.internet import defer
995
+
996
+ @pytest.fixture
997
+ def foo():
998
+ return 37
999
+
1000
+ class TestClass:
1001
+ @pytest_twisted.inlineCallbacks
1002
+ def test_self_isinstance(self, foo):
1003
+ d = defer.succeed(None)
1004
+ yield d
1005
+ assert foo == 37
1006
+ """
1007
+ testdir .makepyfile (test_file )
1008
+ rr = testdir .run (* cmd_opts , timeout = timeout )
1009
+ assert_outcomes (rr , {"passed" : 1 })
1010
+
1011
+
1012
+ @skip_if_no_async_await ()
1013
+ def test_ensuredeferred_method_with_fixture_gets_self (testdir , cmd_opts ):
1014
+ test_file = """
1015
+ import pytest
1016
+ import pytest_twisted
1017
+
1018
+ @pytest.fixture
1019
+ def foo():
1020
+ return 37
1021
+
1022
+ class TestClass:
1023
+ @pytest_twisted.ensureDeferred
1024
+ async def test_self_isinstance(self, foo):
1025
+ assert isinstance(self, TestClass)
1026
+ """
1027
+ testdir .makepyfile (test_file )
1028
+ rr = testdir .run (* cmd_opts , timeout = timeout )
1029
+ assert_outcomes (rr , {"passed" : 1 })
1030
+
1031
+
1032
+ @skip_if_no_async_await ()
1033
+ def test_ensuredeferred_method_with_fixture_gets_fixture (testdir , cmd_opts ):
1034
+ test_file = """
1035
+ import pytest
1036
+ import pytest_twisted
1037
+
1038
+ @pytest.fixture
1039
+ def foo():
1040
+ return 37
1041
+
1042
+ class TestClass:
1043
+ @pytest_twisted.ensureDeferred
1044
+ async def test_self_isinstance(self, foo):
1045
+ assert foo == 37
1046
+ """
1047
+ testdir .makepyfile (test_file )
1048
+ rr = testdir .run (* cmd_opts , timeout = timeout )
1049
+ assert_outcomes (rr , {"passed" : 1 })
0 commit comments