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

Method test_conftest_warning_captured

testing/test_warnings.py:720–731  ·  view source on GitHub ↗

Warnings raised during importing of conftest.py files is captured (#2891).

(self, pytester: Pytester)

Source from the content-addressed store, hash-verified

718
719 @pytest.mark.filterwarnings("default")
720 def test_conftest_warning_captured(self, pytester: Pytester) -> None:
721 """Warnings raised during importing of conftest.py files is captured (#2891)."""
722 pytester.makeconftest(
723 """
724 import warnings
725 warnings.warn(UserWarning("my custom warning"))
726 """
727 )
728 result = pytester.runpytest()
729 result.stdout.fnmatch_lines(
730 ["conftest.py:2", "*UserWarning: my custom warning*"]
731 )
732
733 def test_issue4445_import_plugin(self, pytester: Pytester, capwarn) -> None:
734 """#4445: Make sure the warning points to a reasonable location"""

Callers

nothing calls this directly

Calls 3

fnmatch_linesMethod · 0.80
makeconftestMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected