[issue24352] Provide a way for assertLogs to optionally not hide the logging output

Robert Collins report at bugs.python.org
Fri Aug 21 02:23:36 CEST 2015


Robert Collins added the comment:

Ok so, design thoughts here.

assertLogs really does two things. Firstly it takes a copy of the logs so it can do its assertion.

Secondly it disables all other logging, cleaning up noisy tests.

Your specific need only conflicts with the second case.

The way I handle this in 'fixtures' is to automatically attach the logs to the test output, which means failures show the logs. (Successes have them too, but they are not shown by default).

Ignoring the mismatch between stock unittest and fixtures supporting unittests, does this sound like it would meet your needs? e.g. you'd use your global to make attachments be shown on success as well as failure, and then you'd have nearly identical behaviour. But not exactly:  it would still disable the during-execution output (which makes parallel and CI runs a lot nicer - the report at the end is the key).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24352>
_______________________________________


More information about the Python-bugs-list mailing list