@@ -39,7 +39,7 @@ def foo():
39
39
40
40
41
41
@pytest .mark .filterwarnings ("default" )
42
- def test_normal_flow (pytester : Pytester , pyfile_with_warnings ):
42
+ def test_normal_flow (pytester : Pytester , pyfile_with_warnings ) -> None :
43
43
"""Check that the warnings section is displayed."""
44
44
result = pytester .runpytest (pyfile_with_warnings )
45
45
result .stdout .fnmatch_lines (
@@ -56,7 +56,7 @@ def test_normal_flow(pytester: Pytester, pyfile_with_warnings):
56
56
57
57
58
58
@pytest .mark .filterwarnings ("always" )
59
- def test_setup_teardown_warnings (pytester : Pytester ):
59
+ def test_setup_teardown_warnings (pytester : Pytester ) -> None :
60
60
pytester .makepyfile (
61
61
"""
62
62
import warnings
@@ -86,7 +86,7 @@ def test_func(fix):
86
86
87
87
88
88
@pytest .mark .parametrize ("method" , ["cmdline" , "ini" ])
89
- def test_as_errors (pytester : Pytester , pyfile_with_warnings , method ):
89
+ def test_as_errors (pytester : Pytester , pyfile_with_warnings , method ) -> None :
90
90
args = ("-W" , "error" ) if method == "cmdline" else ()
91
91
if method == "ini" :
92
92
pytester .makeini (
@@ -108,7 +108,7 @@ def test_as_errors(pytester: Pytester, pyfile_with_warnings, method):
108
108
109
109
110
110
@pytest .mark .parametrize ("method" , ["cmdline" , "ini" ])
111
- def test_ignore (pytester : Pytester , pyfile_with_warnings , method ):
111
+ def test_ignore (pytester : Pytester , pyfile_with_warnings , method ) -> None :
112
112
args = ("-W" , "ignore" ) if method == "cmdline" else ()
113
113
if method == "ini" :
114
114
pytester .makeini (
@@ -124,7 +124,7 @@ def test_ignore(pytester: Pytester, pyfile_with_warnings, method):
124
124
125
125
126
126
@pytest .mark .filterwarnings ("always" )
127
- def test_unicode (pytester : Pytester ):
127
+ def test_unicode (pytester : Pytester ) -> None :
128
128
pytester .makepyfile (
129
129
"""
130
130
import warnings
@@ -150,7 +150,7 @@ def test_func(fix):
150
150
)
151
151
152
152
153
- def test_works_with_filterwarnings (pytester : Pytester ):
153
+ def test_works_with_filterwarnings (pytester : Pytester ) -> None :
154
154
"""Ensure our warnings capture does not mess with pre-installed filters (#2430)."""
155
155
pytester .makepyfile (
156
156
"""
@@ -175,7 +175,7 @@ def test_my_warning(self):
175
175
176
176
177
177
@pytest .mark .parametrize ("default_config" , ["ini" , "cmdline" ])
178
- def test_filterwarnings_mark (pytester : Pytester , default_config ):
178
+ def test_filterwarnings_mark (pytester : Pytester , default_config ) -> None :
179
179
"""Test ``filterwarnings`` mark works and takes precedence over command
180
180
line and ini options."""
181
181
if default_config == "ini" :
@@ -206,7 +206,7 @@ def test_show_warning():
206
206
result .stdout .fnmatch_lines (["*= 1 failed, 2 passed, 1 warning in *" ])
207
207
208
208
209
- def test_non_string_warning_argument (pytester : Pytester ):
209
+ def test_non_string_warning_argument (pytester : Pytester ) -> None :
210
210
"""Non-str argument passed to warning breaks pytest (#2956)"""
211
211
pytester .makepyfile (
212
212
"""\
@@ -221,7 +221,7 @@ def test():
221
221
result .stdout .fnmatch_lines (["*= 1 passed, 1 warning in *" ])
222
222
223
223
224
- def test_filterwarnings_mark_registration (pytester : Pytester ):
224
+ def test_filterwarnings_mark_registration (pytester : Pytester ) -> None :
225
225
"""Ensure filterwarnings mark is registered"""
226
226
pytester .makepyfile (
227
227
"""
@@ -237,7 +237,7 @@ def test_func():
237
237
238
238
239
239
@pytest .mark .filterwarnings ("always" )
240
- def test_warning_captured_hook (pytester : Pytester ):
240
+ def test_warning_captured_hook (pytester : Pytester ) -> None :
241
241
pytester .makeconftest (
242
242
"""
243
243
def pytest_configure(config):
@@ -298,7 +298,7 @@ def pytest_warning_recorded(self, warning_message, when, nodeid, location):
298
298
299
299
300
300
@pytest .mark .filterwarnings ("always" )
301
- def test_collection_warnings (pytester : Pytester ):
301
+ def test_collection_warnings (pytester : Pytester ) -> None :
302
302
"""Check that we also capture warnings issued during test collection (#3251)."""
303
303
pytester .makepyfile (
304
304
"""
@@ -322,7 +322,7 @@ def test_foo():
322
322
323
323
324
324
@pytest .mark .filterwarnings ("always" )
325
- def test_mark_regex_escape (pytester : Pytester ):
325
+ def test_mark_regex_escape (pytester : Pytester ) -> None :
326
326
"""@pytest.mark.filterwarnings should not try to escape regex characters (#3936)"""
327
327
pytester .makepyfile (
328
328
r"""
@@ -339,7 +339,7 @@ def test_foo():
339
339
340
340
@pytest .mark .filterwarnings ("default" )
341
341
@pytest .mark .parametrize ("ignore_pytest_warnings" , ["no" , "ini" , "cmdline" ])
342
- def test_hide_pytest_internal_warnings (pytester : Pytester , ignore_pytest_warnings ):
342
+ def test_hide_pytest_internal_warnings (pytester : Pytester , ignore_pytest_warnings ) -> None :
343
343
"""Make sure we can ignore internal pytest warnings using a warnings filter."""
344
344
pytester .makepyfile (
345
345
"""
@@ -378,7 +378,7 @@ def test_bar():
378
378
379
379
380
380
@pytest .mark .parametrize ("ignore_on_cmdline" , [True , False ])
381
- def test_option_precedence_cmdline_over_ini (pytester : Pytester , ignore_on_cmdline ):
381
+ def test_option_precedence_cmdline_over_ini (pytester : Pytester , ignore_on_cmdline ) -> None :
382
382
"""Filters defined in the command-line should take precedence over filters in ini files (#3946)."""
383
383
pytester .makeini (
384
384
"""
@@ -401,7 +401,7 @@ def test():
401
401
result .stdout .fnmatch_lines (["* 1 failed in*" ])
402
402
403
403
404
- def test_option_precedence_mark (pytester : Pytester ):
404
+ def test_option_precedence_mark (pytester : Pytester ) -> None :
405
405
"""Filters defined by marks should always take precedence (#3946)."""
406
406
pytester .makeini (
407
407
"""
@@ -427,7 +427,7 @@ class TestDeprecationWarningsByDefault:
427
427
from pytest's own test suite
428
428
"""
429
429
430
- def create_file (self , pytester : Pytester , mark = "" ):
430
+ def create_file (self , pytester : Pytester , mark = "" ) -> None :
431
431
pytester .makepyfile (
432
432
"""
433
433
import pytest, warnings
@@ -443,7 +443,7 @@ def test_foo():
443
443
)
444
444
445
445
@pytest .mark .parametrize ("customize_filters" , [True , False ])
446
- def test_shown_by_default (self , pytester : Pytester , customize_filters ):
446
+ def test_shown_by_default (self , pytester : Pytester , customize_filters ) -> None :
447
447
"""Show deprecation warnings by default, even if user has customized the warnings filters (#4013)."""
448
448
self .create_file (pytester )
449
449
if customize_filters :
@@ -464,7 +464,7 @@ def test_shown_by_default(self, pytester: Pytester, customize_filters):
464
464
]
465
465
)
466
466
467
- def test_hidden_by_ini (self , pytester : Pytester ):
467
+ def test_hidden_by_ini (self , pytester : Pytester ) -> None :
468
468
self .create_file (pytester )
469
469
pytester .makeini (
470
470
"""
@@ -477,7 +477,7 @@ def test_hidden_by_ini(self, pytester: Pytester):
477
477
result = pytester .runpytest_subprocess ()
478
478
assert WARNINGS_SUMMARY_HEADER not in result .stdout .str ()
479
479
480
- def test_hidden_by_mark (self , pytester : Pytester ):
480
+ def test_hidden_by_mark (self , pytester : Pytester ) -> None :
481
481
"""Should hide the deprecation warning from the function, but the warning during collection should
482
482
be displayed normally.
483
483
"""
@@ -494,7 +494,7 @@ def test_hidden_by_mark(self, pytester: Pytester):
494
494
]
495
495
)
496
496
497
- def test_hidden_by_cmdline (self , pytester : Pytester ):
497
+ def test_hidden_by_cmdline (self , pytester : Pytester ) -> None :
498
498
self .create_file (pytester )
499
499
result = pytester .runpytest_subprocess (
500
500
"-W" ,
@@ -504,7 +504,7 @@ def test_hidden_by_cmdline(self, pytester: Pytester):
504
504
)
505
505
assert WARNINGS_SUMMARY_HEADER not in result .stdout .str ()
506
506
507
- def test_hidden_by_system (self , pytester : Pytester , monkeypatch ):
507
+ def test_hidden_by_system (self , pytester : Pytester , monkeypatch ) -> None :
508
508
self .create_file (pytester )
509
509
monkeypatch .setenv ("PYTHONWARNINGS" , "once::UserWarning" )
510
510
result = pytester .runpytest_subprocess ()
@@ -515,7 +515,7 @@ def test_hidden_by_system(self, pytester: Pytester, monkeypatch):
515
515
@pytest .mark .skip (
516
516
reason = "This test should be enabled again before pytest 7.0 is released"
517
517
)
518
- def test_deprecation_warning_as_error (pytester : Pytester , change_default ):
518
+ def test_deprecation_warning_as_error (pytester : Pytester , change_default ) -> None :
519
519
"""This ensures that PytestDeprecationWarnings raised by pytest are turned into errors.
520
520
521
521
This test should be enabled as part of each major release, and skipped again afterwards
@@ -552,10 +552,10 @@ def test():
552
552
553
553
class TestAssertionWarnings :
554
554
@staticmethod
555
- def assert_result_warns (result , msg ):
555
+ def assert_result_warns (result , msg ) -> None :
556
556
result .stdout .fnmatch_lines (["*PytestAssertRewriteWarning: %s*" % msg ])
557
557
558
- def test_tuple_warning (self , pytester : Pytester ):
558
+ def test_tuple_warning (self , pytester : Pytester ) -> None :
559
559
pytester .makepyfile (
560
560
"""\
561
561
def test_foo():
@@ -568,7 +568,7 @@ def test_foo():
568
568
)
569
569
570
570
571
- def test_warnings_checker_twice ():
571
+ def test_warnings_checker_twice () -> None :
572
572
"""Issue #4617"""
573
573
expectation = pytest .warns (UserWarning )
574
574
with expectation :
@@ -579,7 +579,7 @@ def test_warnings_checker_twice():
579
579
580
580
@pytest .mark .filterwarnings ("ignore::pytest.PytestExperimentalApiWarning" )
581
581
@pytest .mark .filterwarnings ("always" )
582
- def test_group_warnings_by_message (pytester : Pytester ):
582
+ def test_group_warnings_by_message (pytester : Pytester ) -> None :
583
583
pytester .copy_example ("warnings/test_group_warnings_by_message.py" )
584
584
result = pytester .runpytest ()
585
585
result .stdout .fnmatch_lines (
@@ -611,7 +611,7 @@ def test_group_warnings_by_message(pytester: Pytester):
611
611
612
612
@pytest .mark .filterwarnings ("ignore::pytest.PytestExperimentalApiWarning" )
613
613
@pytest .mark .filterwarnings ("always" )
614
- def test_group_warnings_by_message_summary (pytester : Pytester ):
614
+ def test_group_warnings_by_message_summary (pytester : Pytester ) -> None :
615
615
pytester .copy_example ("warnings/test_group_warnings_by_message_summary" )
616
616
pytester .syspathinsert ()
617
617
result = pytester .runpytest ()
@@ -634,7 +634,7 @@ def test_group_warnings_by_message_summary(pytester: Pytester):
634
634
)
635
635
636
636
637
- def test_pytest_configure_warning (pytester : Pytester , recwarn ):
637
+ def test_pytest_configure_warning (pytester : Pytester , recwarn ) -> None :
638
638
"""Issue 5115."""
639
639
pytester .makeconftest (
640
640
"""
@@ -668,7 +668,7 @@ def pytest_warning_recorded(cls, warning_message, when, nodeid, location):
668
668
669
669
return CapturedWarnings
670
670
671
- def test_issue4445_rewrite (self , pytester : Pytester , capwarn ):
671
+ def test_issue4445_rewrite (self , pytester : Pytester , capwarn ) -> None :
672
672
"""#4445: Make sure the warning points to a reasonable location
673
673
See origin of _issue_warning_captured at: _pytest.assertion.rewrite.py:241
674
674
"""
@@ -694,7 +694,7 @@ def test_issue4445_rewrite(self, pytester: Pytester, capwarn):
694
694
assert func == "<module>" # the above conftest.py
695
695
assert lineno == 4
696
696
697
- def test_issue4445_preparse (self , pytester : Pytester , capwarn ):
697
+ def test_issue4445_preparse (self , pytester : Pytester , capwarn ) -> None :
698
698
"""#4445: Make sure the warning points to a reasonable location
699
699
See origin of _issue_warning_captured at: _pytest.config.__init__.py:910
700
700
"""
@@ -729,7 +729,7 @@ def test_conftest_warning_captured(self, pytester: Pytester) -> None:
729
729
["conftest.py:2" , "*UserWarning: my custom warning*" ]
730
730
)
731
731
732
- def test_issue4445_import_plugin (self , pytester : Pytester , capwarn ):
732
+ def test_issue4445_import_plugin (self , pytester : Pytester , capwarn ) -> None :
733
733
"""#4445: Make sure the warning points to a reasonable location"""
734
734
pytester .makepyfile (
735
735
some_plugin = """
@@ -751,7 +751,7 @@ def test_issue4445_import_plugin(self, pytester: Pytester, capwarn):
751
751
assert f"config{ os .sep } __init__.py" in file
752
752
assert func == "_warn_about_skipped_plugins"
753
753
754
- def test_issue4445_issue5928_mark_generator (self , pytester : Pytester ):
754
+ def test_issue4445_issue5928_mark_generator (self , pytester : Pytester ) -> None :
755
755
"""#4445 and #5928: Make sure the warning from an unknown mark points to
756
756
the test file where this mark is used.
757
757
"""
0 commit comments