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

Function test_capture_with_live_logging

testing/test_capture.py:1561–1593  ·  view source on GitHub ↗
(
    pytester: Pytester, capture_fixture: CaptureFixture[str]
)

Source from the content-addressed store, hash-verified

1559
1560@pytest.mark.parametrize("capture_fixture", ["capsys", "capfd"])
1561def test_capture_with_live_logging(
1562 pytester: Pytester, capture_fixture: CaptureFixture[str]
1563) -> None:
1564 # Issue 3819
1565 # capture should work with live cli logging
1566
1567 pytester.makepyfile(
1568 """
1569 import logging
1570 import sys
1571
1572 logger = logging.getLogger(__name__)
1573
1574 def test_capture({0}):
1575 print("hello")
1576 sys.stderr.write("world\\n")
1577 captured = {0}.readouterr()
1578 assert captured.out == "hello\\n"
1579 assert captured.err == "world\\n"
1580
1581 logging.info("something")
1582 print("next")
1583 logging.info("something")
1584
1585 captured = {0}.readouterr()
1586 assert captured.out == "next\\n"
1587 """.format(
1588 capture_fixture
1589 )
1590 )
1591
1592 result = pytester.runpytest_subprocess("--log-cli-level=INFO")
1593 assert result.ret == 0
1594
1595
1596def test_typeerror_encodedfile_write(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

makepyfileMethod · 0.45
formatMethod · 0.45
runpytest_subprocessMethod · 0.45

Tested by

no test coverage detected