@@ -57,34 +57,36 @@ 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 ):
60
+ @pytest .mark .parametrize (
61
+ 'decorator, should_warn' ,
62
+ (
63
+ ('pytest.inlineCallbacks' , True ),
64
+ ('pytest_twisted.inlineCallbacks' , False ),
65
+ ),
66
+ )
67
+ def test_inline_callbacks_in_pytest_deprecation (
68
+ testdir ,
69
+ cmd_opts ,
70
+ decorator ,
71
+ should_warn ,
72
+ ):
73
+ import_path , _ , _ = decorator .rpartition ('.' )
61
74
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")
75
+ import {import_path}
69
76
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
- """
77
+ def test_deprecation():
78
+ @{decorator}
79
+ def f():
80
+ yield 42
81
+ """ .format (import_path = import_path , decorator = decorator )
85
82
testdir .makepyfile (test_file )
86
83
rr = testdir .run (sys .executable , "-m" , "pytest" , "-v" , * cmd_opts )
87
- assert_outcomes (rr , {"passed" : 2 })
84
+
85
+ expected_outcomes = {"passed" : 1 }
86
+ if should_warn :
87
+ expected_outcomes ["warnings" ] = 1
88
+
89
+ assert_outcomes (rr , expected_outcomes )
88
90
89
91
90
92
def test_blockon_in_pytest ():
0 commit comments