@@ -93,37 +93,44 @@ def test_blockon_in_pytest():
93
93
assert hasattr (pytest , 'blockon' )
94
94
95
95
96
- def test_blockon_in_pytest_deprecation (testdir , cmd_opts ):
96
+ @pytest .mark .parametrize (
97
+ 'function, should_warn' ,
98
+ (
99
+ ('pytest.blockon' , True ),
100
+ ('pytest_twisted.blockon' , False ),
101
+ ),
102
+ )
103
+ def test_blockon_in_pytest_deprecation (
104
+ testdir ,
105
+ cmd_opts ,
106
+ function ,
107
+ should_warn ,
108
+ ):
109
+ import_path , _ , _ = function .rpartition ('.' )
97
110
test_file = """
98
111
import warnings
99
112
100
113
from twisted.internet import reactor, defer
101
114
import pytest
102
- import pytest_twisted
103
-
104
- warnings.simplefilter("always")
115
+ import {import_path}
105
116
106
- @pytest.fixture(
107
- scope="module",
108
- params=[
109
- [pytest.blockon, 1],
110
- [pytest_twisted.blockon, 0],
111
- ],
112
- )
117
+ @pytest.fixture
113
118
def foo(request):
114
119
d = defer.Deferred()
115
120
d.callback(None)
116
- with warnings.catch_warnings(record=True) as w:
117
- request.param[0](d)
118
-
119
- return (w, request.param[1])
121
+ {function}(d)
120
122
121
123
def test_succeed(foo):
122
- assert len(foo[0]) == foo[1]
123
- """
124
+ pass
125
+ """ . format ( import_path = import_path , function = function )
124
126
testdir .makepyfile (test_file )
125
127
rr = testdir .run (sys .executable , "-m" , "pytest" , "-v" , * cmd_opts )
126
- assert_outcomes (rr , {"passed" : 2 })
128
+
129
+ expected_outcomes = {"passed" : 1 }
130
+ if should_warn :
131
+ expected_outcomes ["warnings" ] = 1
132
+
133
+ assert_outcomes (rr , expected_outcomes )
127
134
128
135
129
136
def test_fail_later (testdir , cmd_opts ):
0 commit comments