-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live logs (-s / --capture=no) #25
base: develop
Are you sure you want to change the base?
Conversation
This makes a distinction between two features / use cases: 1. Inspection: record and check logs emitted by the code being tested using the `caplog` fixture 2. Reporting: show all logs in case of a failure Implemented through adding a dedicated log handler for the recording. As a bonus, simplifies the capturing logic (no more awkward item.catch_log_handler).
We only need formatted text (hence the stream) for log reporting and for the caplog.text() method. On the other hand, we don't need a list of records for the reporting facility. So, we only leave storing of records in the RecordingHandler class, and use ad hoc solutions using logging.StreamHandler where needed.
Turns out, logging.Handler is an old-style class in Python 2.6, so that in order to use super() we need to make it's subclass a new-style class (through extending 'object' explicitly).
This saves us from unnecessary interaction with the logging subsystem (creating a new handler, configuring it, attaching and removing it afterwards) and opens the way for lots of future optimizations and improvements.
References: * eisensheng#14 ("Integrate with --capture and -v options of pytest") * eisensheng#20 ("Move pytest-logging functionality to pytest-catchlog.")
It seems this breaks using
It seems to work when I use the |
@@ -268,6 +269,11 @@ class CallableStr(CallablePropertyMixin, str): | |||
class CompatLogCaptureFixture(LogCaptureFixture): | |||
"""Backward compatibility with pytest-capturelog.""" | |||
|
|||
def __init__(self, handler, item): | |||
"""Creates a new funcarg.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
funcarg
-> fixture
😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Interesting enough. I'm not sure whether it is right to rely on that some Handler calls I'll add a regression test for this, thank you! 👍 |
Partially resolves #14 ("Integrate with --capture and -v options of pytest"), in a slightly more natural and efficient way than proposed in #20 ("Move pytest-logging functionality to pytest-catchlog.")
Note: this includes changes proposed in PR #24, DO NOT MERGE until #24 is accepted. Also this lacks a proper description in the README.
TODO
record.message
not initialized, add tests