I've seen this question: py.test logging messages and test results/assertions into a single file I've also read documentation here: https://docs.pytest.org/en/latest/logging.html
Neither comes close to a satisfactory solution.
- I don't need assertion results together with logs, but it's OK if they are both in the logs.
- I need all the logs produced during the test, but I don't need them for the tests themselves. I need them for analyzing the test results after the tests failed / succeeded.
- I need logs for both succeeding and for failing tests.
- I need stdout to only contain the summary (eg.
test-name PASSED
). It's OK if the summary also contains the stack trace for failing tests, but it's not essential. - Essentially, I need the test to produce 3 different outputs:
- HTML / JUnit XML artifact for CI.
- CLI minimal output for CI log.
- Extended log for testers / automation team to analyze.
I tried pytest-logs
plugin. As far as I can tell, it can override some default pytest
behavior by displaying all logging while the test runs. This is slightly better than default behavior, but it's still very far from what I need. From the documentation I understand that pytest-catchlog
will conflict with pytest
, and I don't even want to explore that option.
Question
Is this achievable by configuring pytest
or should I write a plugin, or, perhaps, even a plugin won't do it, and I will have to patch pytest
?