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

Function test_logging_while_collecting

testing/test_capture.py:1640–1666  ·  view source on GitHub ↗

Issue #6240: Calls to logging.xxx() during collection causes all logging calls to be duplicated to stderr

(pytester: Pytester)

Source from the content-addressed store, hash-verified

1638
1639
1640def test_logging_while_collecting(pytester: Pytester) -> None:
1641 """Issue #6240: Calls to logging.xxx() during collection causes all logging calls to be duplicated to stderr"""
1642 p = pytester.makepyfile(
1643 """\
1644 import logging
1645
1646 logging.warning("during collection")
1647
1648 def test_logging():
1649 logging.warning("during call")
1650 assert False
1651 """
1652 )
1653 result = pytester.runpytest_subprocess(p)
1654 assert result.ret == ExitCode.TESTS_FAILED
1655 result.stdout.fnmatch_lines(
1656 [
1657 "*test_*.py F*",
1658 "====* FAILURES *====",
1659 "____*____",
1660 "*--- Captured log call*",
1661 "WARNING * during call",
1662 "*1 failed*",
1663 ]
1664 )
1665 result.stdout.no_fnmatch_line("*Captured stderr call*")
1666 result.stdout.no_fnmatch_line("*during collection*")

Callers

nothing calls this directly

Calls 4

fnmatch_linesMethod · 0.80
no_fnmatch_lineMethod · 0.80
makepyfileMethod · 0.45
runpytest_subprocessMethod · 0.45

Tested by

no test coverage detected