[pytest-dev] Trouble accessing captured stderr

Andreas Pelme andreas at pelme.se
Tue Jun 4 07:53:29 CEST 2013


(I somehow missed to reply to the list)

On Tuesday 4 June 2013 at 07:03, Nikolaus Rath wrote:
> @pytest.fixture(autouse=True)
> def add_stderr_check(request, capsys):
> def check_stderr():
> stderr = capsys.readouterr()[1]
> if 'exception' in stderr.lower():
> raise AssertionError('Suspicious output to stderr')
> request.addfinalizer(check_stderr)


Hi,

This might not be the answer to your question, but you should be aware of this issue:

https://bitbucket.org/hpk42/pytest/issue/287/fixture-finalizer-failure-causes-other

Raising exceptions in the fixture teardown will make other fixtures not being teared down, which can cause other tests to fail.

Cheers
Andreas 




More information about the Pytest-dev mailing list