pytest
pytest copied to clipboard
disabling capture in cli doesn't work
Using flag --capture=no or -s should disable capturing.
my venv:
❯ pip list
Package Version
--------- -------
iniconfig 2.1.0
packaging 25.0
pip 24.0
pluggy 1.6.0
Pygments 2.19.2
pytest 8.4.2
❯ python3 --version
Python 3.12.3
my OS:
Ubuntu 24.04 on WSL
the test:
def test_capsys(capsys):
print('Hello World!')
captured = capsys.readouterr()
assert captured.out == 'Hello World!\n'
assert captured.err == ''
To reproduce it, run pytest --capture=no test.py or pytest -s test.py. The test should fail as capture is disabled but it still pass.