Skip to content

Commit 6f1cc17

Browse files
authored
adds changes for complete annotation of functions.
1 parent 56ce5b6 commit 6f1cc17

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

testing/test_warnings.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def foo():
3939

4040

4141
@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:
4343
"""Check that the warnings section is displayed."""
4444
result = pytester.runpytest(pyfile_with_warnings)
4545
result.stdout.fnmatch_lines(
@@ -56,7 +56,7 @@ def test_normal_flow(pytester: Pytester, pyfile_with_warnings):
5656

5757

5858
@pytest.mark.filterwarnings("always")
59-
def test_setup_teardown_warnings(pytester: Pytester):
59+
def test_setup_teardown_warnings(pytester: Pytester) -> None:
6060
pytester.makepyfile(
6161
"""
6262
import warnings
@@ -86,7 +86,7 @@ def test_func(fix):
8686

8787

8888
@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:
9090
args = ("-W", "error") if method == "cmdline" else ()
9191
if method == "ini":
9292
pytester.makeini(
@@ -108,7 +108,7 @@ def test_as_errors(pytester: Pytester, pyfile_with_warnings, method):
108108

109109

110110
@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:
112112
args = ("-W", "ignore") if method == "cmdline" else ()
113113
if method == "ini":
114114
pytester.makeini(
@@ -124,7 +124,7 @@ def test_ignore(pytester: Pytester, pyfile_with_warnings, method):
124124

125125

126126
@pytest.mark.filterwarnings("always")
127-
def test_unicode(pytester: Pytester):
127+
def test_unicode(pytester: Pytester) -> None:
128128
pytester.makepyfile(
129129
"""
130130
import warnings
@@ -150,7 +150,7 @@ def test_func(fix):
150150
)
151151

152152

153-
def test_works_with_filterwarnings(pytester: Pytester):
153+
def test_works_with_filterwarnings(pytester: Pytester) -> None:
154154
"""Ensure our warnings capture does not mess with pre-installed filters (#2430)."""
155155
pytester.makepyfile(
156156
"""
@@ -175,7 +175,7 @@ def test_my_warning(self):
175175

176176

177177
@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:
179179
"""Test ``filterwarnings`` mark works and takes precedence over command
180180
line and ini options."""
181181
if default_config == "ini":
@@ -206,7 +206,7 @@ def test_show_warning():
206206
result.stdout.fnmatch_lines(["*= 1 failed, 2 passed, 1 warning in *"])
207207

208208

209-
def test_non_string_warning_argument(pytester: Pytester):
209+
def test_non_string_warning_argument(pytester: Pytester) -> None:
210210
"""Non-str argument passed to warning breaks pytest (#2956)"""
211211
pytester.makepyfile(
212212
"""\
@@ -221,7 +221,7 @@ def test():
221221
result.stdout.fnmatch_lines(["*= 1 passed, 1 warning in *"])
222222

223223

224-
def test_filterwarnings_mark_registration(pytester: Pytester):
224+
def test_filterwarnings_mark_registration(pytester: Pytester) -> None:
225225
"""Ensure filterwarnings mark is registered"""
226226
pytester.makepyfile(
227227
"""
@@ -237,7 +237,7 @@ def test_func():
237237

238238

239239
@pytest.mark.filterwarnings("always")
240-
def test_warning_captured_hook(pytester: Pytester):
240+
def test_warning_captured_hook(pytester: Pytester) -> None:
241241
pytester.makeconftest(
242242
"""
243243
def pytest_configure(config):
@@ -298,7 +298,7 @@ def pytest_warning_recorded(self, warning_message, when, nodeid, location):
298298

299299

300300
@pytest.mark.filterwarnings("always")
301-
def test_collection_warnings(pytester: Pytester):
301+
def test_collection_warnings(pytester: Pytester) -> None:
302302
"""Check that we also capture warnings issued during test collection (#3251)."""
303303
pytester.makepyfile(
304304
"""
@@ -322,7 +322,7 @@ def test_foo():
322322

323323

324324
@pytest.mark.filterwarnings("always")
325-
def test_mark_regex_escape(pytester: Pytester):
325+
def test_mark_regex_escape(pytester: Pytester) -> None:
326326
"""@pytest.mark.filterwarnings should not try to escape regex characters (#3936)"""
327327
pytester.makepyfile(
328328
r"""
@@ -339,7 +339,7 @@ def test_foo():
339339

340340
@pytest.mark.filterwarnings("default")
341341
@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:
343343
"""Make sure we can ignore internal pytest warnings using a warnings filter."""
344344
pytester.makepyfile(
345345
"""
@@ -378,7 +378,7 @@ def test_bar():
378378

379379

380380
@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:
382382
"""Filters defined in the command-line should take precedence over filters in ini files (#3946)."""
383383
pytester.makeini(
384384
"""
@@ -401,7 +401,7 @@ def test():
401401
result.stdout.fnmatch_lines(["* 1 failed in*"])
402402

403403

404-
def test_option_precedence_mark(pytester: Pytester):
404+
def test_option_precedence_mark(pytester: Pytester) -> None:
405405
"""Filters defined by marks should always take precedence (#3946)."""
406406
pytester.makeini(
407407
"""
@@ -427,7 +427,7 @@ class TestDeprecationWarningsByDefault:
427427
from pytest's own test suite
428428
"""
429429

430-
def create_file(self, pytester: Pytester, mark=""):
430+
def create_file(self, pytester: Pytester, mark="") -> None:
431431
pytester.makepyfile(
432432
"""
433433
import pytest, warnings
@@ -443,7 +443,7 @@ def test_foo():
443443
)
444444

445445
@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:
447447
"""Show deprecation warnings by default, even if user has customized the warnings filters (#4013)."""
448448
self.create_file(pytester)
449449
if customize_filters:
@@ -464,7 +464,7 @@ def test_shown_by_default(self, pytester: Pytester, customize_filters):
464464
]
465465
)
466466

467-
def test_hidden_by_ini(self, pytester: Pytester):
467+
def test_hidden_by_ini(self, pytester: Pytester) -> None:
468468
self.create_file(pytester)
469469
pytester.makeini(
470470
"""
@@ -477,7 +477,7 @@ def test_hidden_by_ini(self, pytester: Pytester):
477477
result = pytester.runpytest_subprocess()
478478
assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
479479

480-
def test_hidden_by_mark(self, pytester: Pytester):
480+
def test_hidden_by_mark(self, pytester: Pytester) -> None:
481481
"""Should hide the deprecation warning from the function, but the warning during collection should
482482
be displayed normally.
483483
"""
@@ -494,7 +494,7 @@ def test_hidden_by_mark(self, pytester: Pytester):
494494
]
495495
)
496496

497-
def test_hidden_by_cmdline(self, pytester: Pytester):
497+
def test_hidden_by_cmdline(self, pytester: Pytester) -> None:
498498
self.create_file(pytester)
499499
result = pytester.runpytest_subprocess(
500500
"-W",
@@ -504,7 +504,7 @@ def test_hidden_by_cmdline(self, pytester: Pytester):
504504
)
505505
assert WARNINGS_SUMMARY_HEADER not in result.stdout.str()
506506

507-
def test_hidden_by_system(self, pytester: Pytester, monkeypatch):
507+
def test_hidden_by_system(self, pytester: Pytester, monkeypatch) -> None:
508508
self.create_file(pytester)
509509
monkeypatch.setenv("PYTHONWARNINGS", "once::UserWarning")
510510
result = pytester.runpytest_subprocess()
@@ -515,7 +515,7 @@ def test_hidden_by_system(self, pytester: Pytester, monkeypatch):
515515
@pytest.mark.skip(
516516
reason="This test should be enabled again before pytest 7.0 is released"
517517
)
518-
def test_deprecation_warning_as_error(pytester: Pytester, change_default):
518+
def test_deprecation_warning_as_error(pytester: Pytester, change_default) -> None:
519519
"""This ensures that PytestDeprecationWarnings raised by pytest are turned into errors.
520520
521521
This test should be enabled as part of each major release, and skipped again afterwards
@@ -552,10 +552,10 @@ def test():
552552

553553
class TestAssertionWarnings:
554554
@staticmethod
555-
def assert_result_warns(result, msg):
555+
def assert_result_warns(result, msg) -> None:
556556
result.stdout.fnmatch_lines(["*PytestAssertRewriteWarning: %s*" % msg])
557557

558-
def test_tuple_warning(self, pytester: Pytester):
558+
def test_tuple_warning(self, pytester: Pytester) -> None:
559559
pytester.makepyfile(
560560
"""\
561561
def test_foo():
@@ -568,7 +568,7 @@ def test_foo():
568568
)
569569

570570

571-
def test_warnings_checker_twice():
571+
def test_warnings_checker_twice() -> None:
572572
"""Issue #4617"""
573573
expectation = pytest.warns(UserWarning)
574574
with expectation:
@@ -579,7 +579,7 @@ def test_warnings_checker_twice():
579579

580580
@pytest.mark.filterwarnings("ignore::pytest.PytestExperimentalApiWarning")
581581
@pytest.mark.filterwarnings("always")
582-
def test_group_warnings_by_message(pytester: Pytester):
582+
def test_group_warnings_by_message(pytester: Pytester) -> None:
583583
pytester.copy_example("warnings/test_group_warnings_by_message.py")
584584
result = pytester.runpytest()
585585
result.stdout.fnmatch_lines(
@@ -611,7 +611,7 @@ def test_group_warnings_by_message(pytester: Pytester):
611611

612612
@pytest.mark.filterwarnings("ignore::pytest.PytestExperimentalApiWarning")
613613
@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:
615615
pytester.copy_example("warnings/test_group_warnings_by_message_summary")
616616
pytester.syspathinsert()
617617
result = pytester.runpytest()
@@ -634,7 +634,7 @@ def test_group_warnings_by_message_summary(pytester: Pytester):
634634
)
635635

636636

637-
def test_pytest_configure_warning(pytester: Pytester, recwarn):
637+
def test_pytest_configure_warning(pytester: Pytester, recwarn) -> None:
638638
"""Issue 5115."""
639639
pytester.makeconftest(
640640
"""
@@ -668,7 +668,7 @@ def pytest_warning_recorded(cls, warning_message, when, nodeid, location):
668668

669669
return CapturedWarnings
670670

671-
def test_issue4445_rewrite(self, pytester: Pytester, capwarn):
671+
def test_issue4445_rewrite(self, pytester: Pytester, capwarn) -> None:
672672
"""#4445: Make sure the warning points to a reasonable location
673673
See origin of _issue_warning_captured at: _pytest.assertion.rewrite.py:241
674674
"""
@@ -694,7 +694,7 @@ def test_issue4445_rewrite(self, pytester: Pytester, capwarn):
694694
assert func == "<module>" # the above conftest.py
695695
assert lineno == 4
696696

697-
def test_issue4445_preparse(self, pytester: Pytester, capwarn):
697+
def test_issue4445_preparse(self, pytester: Pytester, capwarn) -> None:
698698
"""#4445: Make sure the warning points to a reasonable location
699699
See origin of _issue_warning_captured at: _pytest.config.__init__.py:910
700700
"""
@@ -729,7 +729,7 @@ def test_conftest_warning_captured(self, pytester: Pytester) -> None:
729729
["conftest.py:2", "*UserWarning: my custom warning*"]
730730
)
731731

732-
def test_issue4445_import_plugin(self, pytester: Pytester, capwarn):
732+
def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None:
733733
"""#4445: Make sure the warning points to a reasonable location"""
734734
pytester.makepyfile(
735735
some_plugin="""
@@ -751,7 +751,7 @@ def test_issue4445_import_plugin(self, pytester: Pytester, capwarn):
751751
assert f"config{os.sep}__init__.py" in file
752752
assert func == "_warn_about_skipped_plugins"
753753

754-
def test_issue4445_issue5928_mark_generator(self, pytester: Pytester):
754+
def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None:
755755
"""#4445 and #5928: Make sure the warning from an unknown mark points to
756756
the test file where this mark is used.
757757
"""

0 commit comments

Comments
 (0)