How to enable logging when running with --collect-only
#8271
Replies: 1 comment 2 replies
|
This old limitation no longer applies to current pytest. Modern pytest enables its logging handlers around the collection phase itself, so logs emitted while collecting tests can be written to the configured log file even with For example: pytest --collect-only \
--log-file=collection.log \
--log-file-level=INFOor: [pytest]
log_file = collection.log
log_file_level = INFOFor live terminal output during collection you can also use: pytest --collect-only --log-cli-level=INFOThe old If a current pytest run still produces an empty file, check whether the messages are being emitted through Python's standard So today the supported solution is simply the normal Please mark this answer as accepted if it helped, thank you. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I have some custom filtering depending on command line parameters. Some tests are skipped due to something and I want to log the information about why something was skipped. I use standard logging mechanism and run
pytestwith--collect-only -q. I've setlog_print=True,log_level=INFO,log_formatandlog_file. Although the log file is created, it remains empty after execution. I know that my custom filtering is working fine and I'm sure I go through the code which is expected to log some messages.Is it possible to enable logging in this case or I'm doing something wrong?
Thanks,
Jacek
All reactions