(
self, pytester: Pytester, fixture: str, no_capture: bool
)
| 620 | @pytest.mark.parametrize("fixture", ["capsys", "capfd"]) |
| 621 | @pytest.mark.parametrize("no_capture", [True, False]) |
| 622 | def test_disabled_capture_fixture( |
| 623 | self, pytester: Pytester, fixture: str, no_capture: bool |
| 624 | ) -> None: |
| 625 | pytester.makepyfile( |
| 626 | """\ |
| 627 | def test_disabled({fixture}): |
| 628 | print('captured before') |
| 629 | with {fixture}.disabled(): |
| 630 | print('while capture is disabled') |
| 631 | print('captured after') |
| 632 | assert {fixture}.readouterr() == ('captured before\\ncaptured after\\n', '') |
| 633 | |
| 634 | def test_normal(): |
| 635 | print('test_normal executed') |
| 636 | """.format( |
| 637 | fixture=fixture |
| 638 | ) |
| 639 | ) |
| 640 | args = ("-s",) if no_capture else () |
| 641 | result = pytester.runpytest_subprocess(*args) |
| 642 | result.stdout.fnmatch_lines(["*while capture is disabled*", "*= 2 passed in *"]) |
| 643 | result.stdout.no_fnmatch_line("*captured before*") |
| 644 | result.stdout.no_fnmatch_line("*captured after*") |
| 645 | if no_capture: |
| 646 | assert "test_normal executed" in result.stdout.str() |
| 647 | else: |
| 648 | result.stdout.no_fnmatch_line("*test_normal executed*") |
| 649 | |
| 650 | def test_disabled_capture_fixture_twice(self, pytester: Pytester) -> None: |
| 651 | """Test that an inner disabled() exit doesn't undo an outer disabled(). |
nothing calls this directly
no test coverage detected