MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_issue4445_import_plugin

Method test_issue4445_import_plugin

testing/test_warnings.py:733–753  ·  view source on GitHub ↗

#4445: Make sure the warning points to a reasonable location

(self, pytester: Pytester, capwarn)

Source from the content-addressed store, hash-verified

731 )
732
733 def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None:
734 """#4445: Make sure the warning points to a reasonable location"""
735 pytester.makepyfile(
736 some_plugin="""
737 import pytest
738 pytest.skip("thing", allow_module_level=True)
739 """
740 )
741 pytester.syspathinsert()
742 pytester.parseconfig("-p", "some_plugin")
743
744 # with stacklevel=2 the warning should originate from
745 # config.PytestPluginManager.import_plugin is thrown by a skipped plugin
746
747 assert len(capwarn.captured) == 1
748 warning, location = capwarn.captured.pop()
749 file, _, func = location
750
751 assert "skipped plugin 'some_plugin': thing" in str(warning.message)
752 assert f"config{os.sep}__init__.py" in file
753 assert func == "_warn_about_skipped_plugins"
754
755 def test_issue4445_issue5928_mark_generator(self, pytester: Pytester) -> None:
756 """#4445 and #5928: Make sure the warning from an unknown mark points to

Callers

nothing calls this directly

Calls 4

popMethod · 0.80
makepyfileMethod · 0.45
syspathinsertMethod · 0.45
parseconfigMethod · 0.45

Tested by

no test coverage detected