@@ -948,3 +948,43 @@ def test_self_isinstance(self, foo):
948
948
testdir .makepyfile (test_file )
949
949
rr = testdir .run (sys .executable , "-m" , "pytest" , "-v" , * cmd_opts )
950
950
assert_outcomes (rr , {"passed" : 1 })
951
+
952
+
953
+ @skip_if_no_async_await ()
954
+ def test_ensuredeferred_method_with_fixture_gets_self (testdir , cmd_opts ):
955
+ test_file = """
956
+ import pytest
957
+ import pytest_twisted
958
+
959
+ @pytest.fixture
960
+ def foo():
961
+ return 37
962
+
963
+ class TestClass:
964
+ @pytest_twisted.ensureDeferred
965
+ async def test_self_isinstance(self, foo):
966
+ assert isinstance(self, TestClass)
967
+ """
968
+ testdir .makepyfile (test_file )
969
+ rr = testdir .run (sys .executable , "-m" , "pytest" , "-v" , * cmd_opts )
970
+ assert_outcomes (rr , {"passed" : 1 })
971
+
972
+
973
+ @skip_if_no_async_await ()
974
+ def test_ensuredeferred_method_with_fixture_gets_fixture (testdir , cmd_opts ):
975
+ test_file = """
976
+ import pytest
977
+ import pytest_twisted
978
+
979
+ @pytest.fixture
980
+ def foo():
981
+ return 37
982
+
983
+ class TestClass:
984
+ @pytest_twisted.ensureDeferred
985
+ async def test_self_isinstance(self, foo):
986
+ assert foo == 37
987
+ """
988
+ testdir .makepyfile (test_file )
989
+ rr = testdir .run (sys .executable , "-m" , "pytest" , "-v" , * cmd_opts )
990
+ assert_outcomes (rr , {"passed" : 1 })
0 commit comments