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

Method test_issue4445_preparse

testing/test_warnings.py:698–717  ·  view source on GitHub ↗

#4445: Make sure the warning points to a reasonable location See origin of _issue_warning_captured at: _pytest.config.__init__.py:910

(self, pytester: Pytester, capwarn)

Source from the content-addressed store, hash-verified

696 assert lineno == 4
697
698 def test_issue4445_preparse(self, pytester: Pytester, capwarn) -> None:
699 """#4445: Make sure the warning points to a reasonable location
700 See origin of _issue_warning_captured at: _pytest.config.__init__.py:910
701 """
702 pytester.makeconftest(
703 """
704 import nothing
705 """
706 )
707 pytester.parseconfig("--help")
708
709 # with stacklevel=2 the warning should originate from config._preparse and is
710 # thrown by an erroneous conftest.py
711 assert len(capwarn.captured) == 1
712 warning, location = capwarn.captured.pop()
713 file, _, func = location
714
715 assert "could not load initial conftests" in str(warning.message)
716 assert f"config{os.sep}__init__.py" in file
717 assert func == "_preparse"
718
719 @pytest.mark.filterwarnings("default")
720 def test_conftest_warning_captured(self, pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

popMethod · 0.80
makeconftestMethod · 0.45
parseconfigMethod · 0.45

Tested by

no test coverage detected