(
pytester: Pytester, capture_fixture: CaptureFixture[str]
)
| 1559 | |
| 1560 | @pytest.mark.parametrize("capture_fixture", ["capsys", "capfd"]) |
| 1561 | def 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 | |
| 1596 | def test_typeerror_encodedfile_write(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected