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:
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.
Using flag
--capture=noor-sshould disable capturing.my venv:
my OS:
the test:
To reproduce it, run
pytest --capture=no test.pyorpytest -s test.py. The test should fail as capture is disabled but it still pass.