Exclude stdout/stderr log sections when --report-log-exclude-logs-on-passed-tests is given#96
Exclude stdout/stderr log sections when --report-log-exclude-logs-on-passed-tests is given#96ento wants to merge 1 commit intopytest-dev:mainfrom
Conversation
…passed-tests is given
|
this constitutes as breaking change - perhaps a option to configure whats skipped also i wonder why your output is so big - because i don't want this option in here if all it does is work around missconfigured logging thats using the stderr fallback |
Pytest's Junit XML reporter's But I'm happy to do it as a separate option if that's better. Any suggestion as to the flag name?
The project uses Django + structlog (through its stdlib integration), but it seems it boils down to the use of With a test file that sets up a logging.config.dictConfig({
"version": 1,
"handlers": {
"console": {
"class": "logging.StreamHandler",
}
},
"loggers": {
"": {"handlers": ["console"], "level": "INFO"},
}
})Logging output shows up in both "Captured stderr call" and "Captured log call" sections. ------------------ Captured stderr call -------------------
dictConfig failure stderr
dictConfig failure log
-------------------- Captured log call --------------------
CRITICAL root:test_dict_config.py:28 dictConfig failure logminimally reproducible scriptShould logging be set up in a specific way/timing when integrating with pytest? Even if this duplication is dealt with in some way, strings written directly to stdout/stderr will still be included in pytest-reportlog's output, which will be unexpected when |
|
As far as I'm concerned configuration of Studio logging output under test with capture constitutes missconfiguration |
|
Setting up logging using a code snippet from Python's official "Logging HOWTO" doc still results in the same duplication. (I've updated the reproducible example in my previous comment to do the logging setup in a separate file to simulate a real code base more closely.) pytest's documentation on logging doesn't mention any need for a special setup, so I'm not sure what configuration is expected from pytest's side. Regardless, it still stands that pytest-reportlog doesn't expose a way to control whether to include stdout/stderr sections for passing tests like the junit xml reporter does. It's alright if project maintainers think that such an option is unnecessary, but I think it's something to consider separately from any logging misconfiguration. |
I noticed that the size of the log file written by this plugin was 100MB+, and sections like "Captured stderr call" were included, even though I'd specified the
--report-log-exclude-logs-on-passed-testsflag.Would it make sense to make the flag also exclude captured outputs too, in addition to captured logs?
If I'm reading it right, junitxml's
log_passing_testssetting covers both stdout/stderr outputs and logging outputs:https://github.com/pytest-dev/pytest/blob/9.0.2/src/_pytest/junitxml.py#L159-L180