@@ -57,10 +57,73 @@ def test_inline_callbacks_in_pytest():
57
57
assert hasattr (pytest , 'inlineCallbacks' )
58
58
59
59
60
+ def test_inline_callbacks_in_pytest_deprecation (testdir , cmd_opts ):
61
+ test_file = """
62
+ import warnings
63
+
64
+ from twisted.internet import reactor, defer
65
+ import pytest
66
+ import pytest_twisted
67
+
68
+ warnings.simplefilter("always")
69
+
70
+ @pytest.mark.parametrize(
71
+ argnames='decorator, warning_count',
72
+ argvalues=[
73
+ [pytest.inlineCallbacks, 1],
74
+ [pytest_twisted.inlineCallbacks, 0],
75
+ ],
76
+ )
77
+ def test_inline_callbacks_in_pytest_deprecated(decorator, warning_count):
78
+ with warnings.catch_warnings(record=True) as w:
79
+ @decorator
80
+ def f():
81
+ yield 42
82
+
83
+ assert len(w) == warning_count
84
+ """
85
+ testdir .makepyfile (test_file )
86
+ rr = testdir .run (sys .executable , "-m" , "pytest" , "-v" , * cmd_opts )
87
+ assert_outcomes (rr , {"passed" : 2 })
88
+
89
+
60
90
def test_blockon_in_pytest ():
61
91
assert hasattr (pytest , 'blockon' )
62
92
63
93
94
+ def test_blockon_in_pytest_deprecation (testdir , cmd_opts ):
95
+ test_file = """
96
+ import warnings
97
+
98
+ from twisted.internet import reactor, defer
99
+ import pytest
100
+ import pytest_twisted
101
+
102
+ warnings.simplefilter("always")
103
+
104
+ @pytest.fixture(
105
+ scope="module",
106
+ params=[
107
+ [pytest.blockon, 1],
108
+ [pytest_twisted.blockon, 0],
109
+ ],
110
+ )
111
+ def foo(request):
112
+ d = defer.Deferred()
113
+ d.callback(None)
114
+ with warnings.catch_warnings(record=True) as w:
115
+ request.param[0](d)
116
+
117
+ return (w, request.param[1])
118
+
119
+ def test_succeed(foo):
120
+ assert len(foo[0]) == foo[1]
121
+ """
122
+ testdir .makepyfile (test_file )
123
+ rr = testdir .run (sys .executable , "-m" , "pytest" , "-v" , * cmd_opts )
124
+ assert_outcomes (rr , {"passed" : 2 })
125
+
126
+
64
127
def test_fail_later (testdir , cmd_opts ):
65
128
test_file = """
66
129
from twisted.internet import reactor, defer
0 commit comments