add fixture to capture output in tests less fragile

Now we always remove previous output before capturing.
This commit is contained in:
Jörg Thalheim
2024-08-15 18:21:27 +02:00
parent aec45d3a1a
commit fe66a740b5
6 changed files with 50 additions and 24 deletions

View File

@@ -1,9 +1,9 @@
import pytest
from helpers import cli
from stdout import CaptureOutput
def test_help(capsys: pytest.CaptureFixture) -> None:
with pytest.raises(SystemExit):
def test_help(capture_output: CaptureOutput) -> None:
with capture_output as output, pytest.raises(SystemExit):
cli.run(["--help"])
captured = capsys.readouterr()
assert captured.out.startswith("usage:")
assert output.out.startswith("usage:")