5
5
import os
6
6
7
7
import pytest
8
+ from _pytest .warnings import SHOW_PYTEST_WARNINGS_ARG
8
9
9
10
pytestmark = pytest .mark .pytester_example_path ("deprecated" )
10
11
11
12
12
- @pytest .mark .filterwarnings ("default" )
13
13
def test_yield_tests_deprecation (testdir ):
14
14
testdir .makepyfile (
15
15
"""
@@ -23,7 +23,7 @@ def test_gen2():
23
23
yield func1, 1, 1
24
24
"""
25
25
)
26
- result = testdir .runpytest ()
26
+ result = testdir .runpytest (SHOW_PYTEST_WARNINGS_ARG )
27
27
result .stdout .fnmatch_lines (
28
28
[
29
29
"*test_yield_tests_deprecation.py:3:*yield tests are deprecated*" ,
@@ -41,7 +41,7 @@ def test_foo(request):
41
41
print(request.node.Module)
42
42
"""
43
43
)
44
- result = testdir .runpytest ()
44
+ result = testdir .runpytest (SHOW_PYTEST_WARNINGS_ARG )
45
45
result .stdout .fnmatch_lines (
46
46
[
47
47
"*test_compat_properties_deprecation.py:2:*usage of Function.Module is deprecated, "
@@ -63,7 +63,7 @@ def test_foo(fix):
63
63
assert fix == 1
64
64
"""
65
65
)
66
- result = testdir .runpytest ()
66
+ result = testdir .runpytest (SHOW_PYTEST_WARNINGS_ARG )
67
67
result .stdout .fnmatch_lines (
68
68
[
69
69
"*test_cached_setup_deprecation.py:4:*cached_setup is deprecated*" ,
@@ -93,7 +93,7 @@ def test_foo(self):
93
93
pass
94
94
"""
95
95
)
96
- result = testdir .runpytest ()
96
+ result = testdir .runpytest (SHOW_PYTEST_WARNINGS_ARG )
97
97
result .stdout .fnmatch_lines (
98
98
[
99
99
'*test_custom_class_deprecation.py:1:*"Class" objects in collectors of type "MyModule*' ,
@@ -102,7 +102,6 @@ def test_foo(self):
102
102
)
103
103
104
104
105
- @pytest .mark .filterwarnings ("default" )
106
105
def test_funcarg_prefix_deprecation (testdir ):
107
106
testdir .makepyfile (
108
107
"""
@@ -113,7 +112,7 @@ def test_funcarg_prefix(value):
113
112
assert value == 10
114
113
"""
115
114
)
116
- result = testdir .runpytest ("-ra" )
115
+ result = testdir .runpytest ("-ra" , SHOW_PYTEST_WARNINGS_ARG )
117
116
result .stdout .fnmatch_lines (
118
117
[
119
118
(
@@ -198,7 +197,6 @@ def test():
198
197
)
199
198
200
199
201
- @pytest .mark .filterwarnings ("always:Metafunc.addcall is deprecated" )
202
200
def test_metafunc_addcall_deprecated (testdir ):
203
201
testdir .makepyfile (
204
202
"""
@@ -209,7 +207,7 @@ def test_func(i):
209
207
pass
210
208
"""
211
209
)
212
- res = testdir .runpytest ("-s" )
210
+ res = testdir .runpytest ("-s" , SHOW_PYTEST_WARNINGS_ARG )
213
211
assert res .ret == 0
214
212
res .stdout .fnmatch_lines (
215
213
["*Metafunc.addcall is deprecated*" , "*2 passed, 2 warnings*" ]
@@ -263,7 +261,7 @@ def test_func():
263
261
pass
264
262
"""
265
263
)
266
- res = testdir .runpytest ()
264
+ res = testdir .runpytest (SHOW_PYTEST_WARNINGS_ARG )
267
265
assert res .ret == 0
268
266
msg = str (PYTEST_PLUGINS_FROM_NON_TOP_LEVEL_CONFTEST ).splitlines ()[0 ]
269
267
res .stdout .fnmatch_lines (
@@ -292,6 +290,7 @@ def test_pytest_plugins_in_non_top_level_conftest_deprecated_pyargs(
292
290
testdir .syspathinsert (testdir .tmpdir .join ("src" ))
293
291
294
292
args = ("--pyargs" , "pkg" ) if use_pyargs else ()
293
+ args += (SHOW_PYTEST_WARNINGS_ARG ,)
295
294
res = testdir .runpytest (* args )
296
295
assert res .ret == 0
297
296
msg = str (PYTEST_PLUGINS_FROM_NON_TOP_LEVEL_CONFTEST ).splitlines ()[0 ]
0 commit comments