fname
stringlengths
63
176
rel_fname
stringclasses
706 values
line
int64
-1
4.5k
name
stringlengths
1
81
kind
stringclasses
2 values
category
stringclasses
2 values
info
stringlengths
0
77.9k
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
558
fnmatch_lines
ref
function
result.stdout.fnmatch_lines(["*PytestAssertRewriteWarning: %s*" % msg])
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
560
test_tuple_warning
def
function
def test_tuple_warning(self, pytester: Pytester) -> None: pytester.makepyfile( """\ def test_foo(): assert (1,2) """ ) result = pytester.runpytest() self.assert_result_warns( result, "assertion is always true, perhaps remove parentheses?" )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
561
makepyfile
ref
function
pytester.makepyfile(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
567
runpytest
ref
function
result = pytester.runpytest()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
568
assert_result_warns
ref
function
self.assert_result_warns(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
573
test_warnings_checker_twice
def
function
def test_warnings_checker_twice() -> None: """Issue #4617""" expectation = pytest.warns(UserWarning) with expectation: warnings.warn("Message A", UserWarning) with expectation: warnings.warn("Message B", UserWarning)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
575
warns
ref
function
expectation = pytest.warns(UserWarning)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
577
warn
ref
function
warnings.warn("Message A", UserWarning)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
579
warn
ref
function
warnings.warn("Message B", UserWarning)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
582
filterwarnings
ref
function
@pytest.mark.filterwarnings("always::UserWarning")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
583
test_group_warnings_by_message
def
function
def test_group_warnings_by_message(pytester: Pytester) -> None: pytester.copy_example("warnings/test_group_warnings_by_message.py") result = pytester.runpytest() result.stdout.fnmatch_lines( [ "*== %s ==*" % WARNINGS_SUMMARY_HEADER, "test_group_warnings_by_message.py::test_foo[[]0[]]", "test_group_warnings_by_message.py::test_foo[[]1[]]", "test_group_warnings_by_message.py::test_foo[[]2[]]", "test_group_warnings_by_message.py::test_foo[[]3[]]", "test_group_warnings_by_message.py::test_foo[[]4[]]", "test_group_warnings_by_message.py::test_foo_1", " */test_group_warnings_by_message.py:*: UserWarning: foo", " warnings.warn(UserWarning(msg))", "", "test_group_warnings_by_message.py::test_bar[[]0[]]", "test_group_warnings_by_message.py::test_bar[[]1[]]", "test_group_warnings_by_message.py::test_bar[[]2[]]", "test_group_warnings_by_message.py::test_bar[[]3[]]", "test_group_warnings_by_message.py::test_bar[[]4[]]", " */test_group_warnings_by_message.py:*: UserWarning: bar", " warnings.warn(UserWarning(msg))", "", "-- Docs: *", "*= 11 passed, 11 warnings *", ], consecutive=_True, )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
584
copy_example
ref
function
pytester.copy_example("warnings/test_group_warnings_by_message.py")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
585
runpytest
ref
function
result = pytester.runpytest()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
586
fnmatch_lines
ref
function
result.stdout.fnmatch_lines(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
613
filterwarnings
ref
function
@pytest.mark.filterwarnings("always::UserWarning")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
614
test_group_warnings_by_message_summary
def
function
def test_group_warnings_by_message_summary(pytester: Pytester) -> None: pytester.copy_example("warnings/test_group_warnings_by_message_summary") pytester.syspathinsert() result = pytester.runpytest() result.stdout.fnmatch_lines( [ "*== %s ==*" % WARNINGS_SUMMARY_HEADER, "test_1.py: 21 warnings", "test_2.py: 1 warning", " */test_1.py:7: UserWarning: foo", " warnings.warn(UserWarning(msg))", "", "test_1.py: 20 warnings", " */test_1.py:7: UserWarning: bar", " warnings.warn(UserWarning(msg))", "", "-- Docs: *", "*= 42 passed, 42 warnings *", ], consecutive=_True, )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
615
copy_example
ref
function
pytester.copy_example("warnings/test_group_warnings_by_message_summary")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
616
syspathinsert
ref
function
pytester.syspathinsert()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
617
runpytest
ref
function
result = pytester.runpytest()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
618
fnmatch_lines
ref
function
result.stdout.fnmatch_lines(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
637
test_pytest_configure_warning
def
function
def test_pytest_configure_warning(pytester: Pytester, recwarn) -> None: """Issue 5115.""" pytester.makeconftest( """ def pytest_configure(): import warnings warnings.warn("from pytest_configure") """ ) result = pytester.runpytest() assert result.ret == 5 assert "INTERNALERROR" not in result.stderr.str() warning = recwarn.pop() assert str(warning.message) == "from pytest_configure"
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
639
makeconftest
ref
function
pytester.makeconftest(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
648
runpytest
ref
function
result = pytester.runpytest()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
655
TestStackLevel
def
class
capwarn test_issue4445_rewrite test_issue4445_preparse test_conftest_warning_captured test_issue4445_import_plugin test_issue4445_issue5928_mark_generator
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
657
capwarn
def
function
def capwarn(self, pytester: Pytester): class CapturedWarnings: captured: List[ Tuple[warnings.WarningMessage, Optional[Tuple[str, int, str]]] ] = [] @classmethod def pytest_warning_recorded(cls, warning_message, when, nodeid, location): cls.captured.append((warning_message, location)) pytester.plugins = [CapturedWarnings()] return CapturedWarnings def test_issue4445_rewrite(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location See origin of _issue_warning_captured at: _pytest.assertion.rewrite.py:241 """ pytester.makepyfile(some_mod="") conftest = pytester.makeconftest( """ import some_mod import pytest pytest.register_assert_rewrite("some_mod") """ ) pytester.parseconfig() # with stacklevel=5 the warning originates from register_assert_rewrite # function in the created conftest.py assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, lineno, func = location assert "Module already imported" in str(warning.message) assert file == str(conftest) assert func == "<module>" # the above conftest.py assert lineno == 4 def test_issue4445_preparse(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location See origin of _issue_warning_captured at: _pytest.config.__init__.py:910 """ pytester.makeconftest( """ import nothing """ ) pytester.parseconfig("--help") # with stacklevel=2 the warning should originate from config._preparse and is # thrown by an errorneous conftest.py assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "could not load initial conftests" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_preparse" @pytest.mark.filterwarnings("default") def test_conftest_warning_captured(self, pytester: Pytester) -> None: """Warnings raised during importing of conftest.py files is captured (#2891).""" pytester.makeconftest( """ import warnings warnings.warn(UserWarning("my custom warning")) """ ) result = pytester.runpytest() result.stdout.fnmatch_lines( ["conftest.py:2", "*UserWarning: my custom warning*"] ) def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location""" pytester.makepyfile( some_plugin=""" import pytest pytest.skip("thing", allow_module_level=_True) """ ) pytester.syspathinsert() pytester.parseconfig("-p", "some_plugin") # with stacklevel=2 the warning should originate from # config.PytestPluginManager.import_plugin is thrown by a skipped plugin assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "skipped plugin 'some_plugin': thing" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_warn_about_skipped_plugins" def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None: """#4445 and #5928: Make sure the warning from an unknown mark points to the test file where this mark is used. """ testfile = pytester.makepyfile( """ import pytest @pytest.mark.unknown def test_it(): pass """ ) result = pytester.runpytest_subprocess() # with stacklevel=2 the warning should originate from the above created test file result.stdout.fnmatch_lines_random( [ f"*{testfile}:3*", "*Unknown pytest.mark.unknown*", ] )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
658
CapturedWarnings
def
class
pytest_warning_recorded
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
664
pytest_warning_recorded
def
function
def pytest_warning_recorded(cls, warning_message, when, nodeid, location): cls.captured.append((warning_message, location)) pytester.plugins = [CapturedWarnings()] return CapturedWarnings def test_issue4445_rewrite(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location See origin of _issue_warning_captured at: _pytest.assertion.rewrite.py:241 """ pytester.makepyfile(some_mod="") conftest = pytester.makeconftest( """ import some_mod import pytest pytest.register_assert_rewrite("some_mod") """ ) pytester.parseconfig() # with stacklevel=5 the warning originates from register_assert_rewrite # function in the created conftest.py assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, lineno, func = location assert "Module already imported" in str(warning.message) assert file == str(conftest) assert func == "<module>" # the above conftest.py assert lineno == 4 def test_issue4445_preparse(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location See origin of _issue_warning_captured at: _pytest.config.__init__.py:910 """ pytester.makeconftest( """ import nothing """ ) pytester.parseconfig("--help") # with stacklevel=2 the warning should originate from config._preparse and is # thrown by an errorneous conftest.py assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "could not load initial conftests" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_preparse" @pytest.mark.filterwarnings("default") def test_conftest_warning_captured(self, pytester: Pytester) -> None: """Warnings raised during importing of conftest.py files is captured (#2891).""" pytester.makeconftest( """ import warnings warnings.warn(UserWarning("my custom warning")) """ ) result = pytester.runpytest() result.stdout.fnmatch_lines( ["conftest.py:2", "*UserWarning: my custom warning*"] ) def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location""" pytester.makepyfile( some_plugin=""" import pytest pytest.skip("thing", allow_module_level=_True) """ ) pytester.syspathinsert() pytester.parseconfig("-p", "some_plugin") # with stacklevel=2 the warning should originate from # config.PytestPluginManager.import_plugin is thrown by a skipped plugin assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "skipped plugin 'some_plugin': thing" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_warn_about_skipped_plugins" def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None: """#4445 and #5928: Make sure the warning from an unknown mark points to the test file where this mark is used. """ testfile = pytester.makepyfile( """ import pytest @pytest.mark.unknown def test_it(): pass """ ) result = pytester.runpytest_subprocess() # with stacklevel=2 the warning should originate from the above created test file result.stdout.fnmatch_lines_random( [ f"*{testfile}:3*", "*Unknown pytest.mark.unknown*", ] )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
667
CapturedWarnings
ref
function
pytester.plugins = [CapturedWarnings()]
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
671
test_issue4445_rewrite
def
function
def test_issue4445_rewrite(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location See origin of _issue_warning_captured at: _pytest.assertion.rewrite.py:241 """ pytester.makepyfile(some_mod="") conftest = pytester.makeconftest( """ import some_mod import pytest pytest.register_assert_rewrite("some_mod") """ ) pytester.parseconfig() # with stacklevel=5 the warning originates from register_assert_rewrite # function in the created conftest.py assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, lineno, func = location assert "Module already imported" in str(warning.message) assert file == str(conftest) assert func == "<module>" # the above conftest.py assert lineno == 4 def test_issue4445_preparse(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location See origin of _issue_warning_captured at: _pytest.config.__init__.py:910 """ pytester.makeconftest( """ import nothing """ ) pytester.parseconfig("--help") # with stacklevel=2 the warning should originate from config._preparse and is # thrown by an errorneous conftest.py assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "could not load initial conftests" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_preparse" @pytest.mark.filterwarnings("default") def test_conftest_warning_captured(self, pytester: Pytester) -> None: """Warnings raised during importing of conftest.py files is captured (#2891).""" pytester.makeconftest( """ import warnings warnings.warn(UserWarning("my custom warning")) """ ) result = pytester.runpytest() result.stdout.fnmatch_lines( ["conftest.py:2", "*UserWarning: my custom warning*"] ) def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location""" pytester.makepyfile( some_plugin=""" import pytest pytest.skip("thing", allow_module_level=_True) """ ) pytester.syspathinsert() pytester.parseconfig("-p", "some_plugin") # with stacklevel=2 the warning should originate from # config.PytestPluginManager.import_plugin is thrown by a skipped plugin assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "skipped plugin 'some_plugin': thing" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_warn_about_skipped_plugins" def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None: """#4445 and #5928: Make sure the warning from an unknown mark points to the test file where this mark is used. """ testfile = pytester.makepyfile( """ import pytest @pytest.mark.unknown def test_it(): pass """ ) result = pytester.runpytest_subprocess() # with stacklevel=2 the warning should originate from the above created test file result.stdout.fnmatch_lines_random( [ f"*{testfile}:3*", "*Unknown pytest.mark.unknown*", ] )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
675
makepyfile
ref
function
pytester.makepyfile(some_mod="")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
676
makeconftest
ref
function
conftest = pytester.makeconftest(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
684
parseconfig
ref
function
pytester.parseconfig()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
697
test_issue4445_preparse
def
function
def test_issue4445_preparse(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location See origin of _issue_warning_captured at: _pytest.config.__init__.py:910 """ pytester.makeconftest( """ import nothing """ ) pytester.parseconfig("--help") # with stacklevel=2 the warning should originate from config._preparse and is # thrown by an errorneous conftest.py assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "could not load initial conftests" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_preparse" @pytest.mark.filterwarnings("default") def test_conftest_warning_captured(self, pytester: Pytester) -> None: """Warnings raised during importing of conftest.py files is captured (#2891).""" pytester.makeconftest( """ import warnings warnings.warn(UserWarning("my custom warning")) """ ) result = pytester.runpytest() result.stdout.fnmatch_lines( ["conftest.py:2", "*UserWarning: my custom warning*"] ) def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location""" pytester.makepyfile( some_plugin=""" import pytest pytest.skip("thing", allow_module_level=_True) """ ) pytester.syspathinsert() pytester.parseconfig("-p", "some_plugin") # with stacklevel=2 the warning should originate from # config.PytestPluginManager.import_plugin is thrown by a skipped plugin assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "skipped plugin 'some_plugin': thing" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_warn_about_skipped_plugins" def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None: """#4445 and #5928: Make sure the warning from an unknown mark points to the test file where this mark is used. """ testfile = pytester.makepyfile( """ import pytest @pytest.mark.unknown def test_it(): pass """ ) result = pytester.runpytest_subprocess() # with stacklevel=2 the warning should originate from the above created test file result.stdout.fnmatch_lines_random( [ f"*{testfile}:3*", "*Unknown pytest.mark.unknown*", ] )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
701
makeconftest
ref
function
pytester.makeconftest(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
706
parseconfig
ref
function
pytester.parseconfig("--help")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
718
filterwarnings
ref
function
@pytest.mark.filterwarnings("default")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
719
test_conftest_warning_captured
def
function
def test_conftest_warning_captured(self, pytester: Pytester) -> None: """Warnings raised during importing of conftest.py files is captured (#2891).""" pytester.makeconftest( """ import warnings warnings.warn(UserWarning("my custom warning")) """ ) result = pytester.runpytest() result.stdout.fnmatch_lines( ["conftest.py:2", "*UserWarning: my custom warning*"] ) def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location""" pytester.makepyfile( some_plugin=""" import pytest pytest.skip("thing", allow_module_level=_True) """ ) pytester.syspathinsert() pytester.parseconfig("-p", "some_plugin") # with stacklevel=2 the warning should originate from # config.PytestPluginManager.import_plugin is thrown by a skipped plugin assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "skipped plugin 'some_plugin': thing" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_warn_about_skipped_plugins" def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None: """#4445 and #5928: Make sure the warning from an unknown mark points to the test file where this mark is used. """ testfile = pytester.makepyfile( """ import pytest @pytest.mark.unknown def test_it(): pass """ ) result = pytester.runpytest_subprocess() # with stacklevel=2 the warning should originate from the above created test file result.stdout.fnmatch_lines_random( [ f"*{testfile}:3*", "*Unknown pytest.mark.unknown*", ] )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
721
makeconftest
ref
function
pytester.makeconftest(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
727
runpytest
ref
function
result = pytester.runpytest()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
728
fnmatch_lines
ref
function
result.stdout.fnmatch_lines(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
732
test_issue4445_import_plugin
def
function
def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None: """#4445: Make sure the warning points to a reasonable location""" pytester.makepyfile( some_plugin=""" import pytest pytest.skip("thing", allow_module_level=_True) """ ) pytester.syspathinsert() pytester.parseconfig("-p", "some_plugin") # with stacklevel=2 the warning should originate from # config.PytestPluginManager.import_plugin is thrown by a skipped plugin assert len(capwarn.captured) == 1 warning, location = capwarn.captured.pop() file, _, func = location assert "skipped plugin 'some_plugin': thing" in str(warning.message) assert f"config{os.sep}__init__.py" in file assert func == "_warn_about_skipped_plugins" def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None: """#4445 and #5928: Make sure the warning from an unknown mark points to the test file where this mark is used. """ testfile = pytester.makepyfile( """ import pytest @pytest.mark.unknown def test_it(): pass """ ) result = pytester.runpytest_subprocess() # with stacklevel=2 the warning should originate from the above created test file result.stdout.fnmatch_lines_random( [ f"*{testfile}:3*", "*Unknown pytest.mark.unknown*", ] )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
734
makepyfile
ref
function
pytester.makepyfile(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
740
syspathinsert
ref
function
pytester.syspathinsert()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
741
parseconfig
ref
function
pytester.parseconfig("-p", "some_plugin")
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
754
test_issue4445_issue5928_mark_generator
def
function
def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None: """#4445 and #5928: Make sure the warning from an unknown mark points to the test file where this mark is used. """ testfile = pytester.makepyfile( """ import pytest @pytest.mark.unknown def test_it(): pass """ ) result = pytester.runpytest_subprocess() # with stacklevel=2 the warning should originate from the above created test file result.stdout.fnmatch_lines_random( [ f"*{testfile}:3*", "*Unknown pytest.mark.unknown*", ] )
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
758
makepyfile
ref
function
testfile = pytester.makepyfile(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
767
runpytest_subprocess
ref
function
result = pytester.runpytest_subprocess()
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/test_warnings.py
testing/test_warnings.py
769
fnmatch_lines_random
ref
function
result.stdout.fnmatch_lines_random(
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/typing_checks.py
testing/typing_checks.py
9
xfail
ref
function
@pytest.mark.xfail(raises=RuntimeError)
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/typing_checks.py
testing/typing_checks.py
10
check_mark_xfail_raises
def
function
def check_mark_xfail_raises() -> None: pass
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/typing_checks.py
testing/typing_checks.py
15
fixture
ref
function
@pytest.fixture(params=[(0, 0), (1, 1)], ids=lambda x: str(x[0]))
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/typing_checks.py
testing/typing_checks.py
16
check_fixture_ids_callable
def
function
def check_fixture_ids_callable() -> None: pass
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/typing_checks.py
testing/typing_checks.py
21
parametrize
ref
function
@pytest.mark.parametrize("func", [str, int], ids=lambda x: str(x.__name__))
playground/5d9c10a9-c67f-4d61-a0f0-c84c5a279fa1/pytest/testing/typing_checks.py
testing/typing_checks.py
22
check_parametrize_ids_callable
def
function
def check_parametrize_ids_callable(func) -> None: pass