-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fix #3297 where caplog.clear() did not clear text, just records #3301
Fix #3297 where caplog.clear() did not clear text, just records #3301
Conversation
9ec8355
to
d256b09
Compare
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.
Thanks a lot @ankostis!
The only thing missing is a changelog entry, please create a file named changelog/3297.bugfix.rst
describing this change, I suggest:
``caplog.clear`` now also properly clears the ``text`` property.
@@ -176,6 +176,10 @@ def emit(self, record): | |||
self.records.append(record) | |||
logging.StreamHandler.emit(self, record) | |||
|
|||
def reset(self): |
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.
For consistency perhaps we should call this clear
too?
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.
But i see that there pre-existed also _LiveLoggingStreamHandler.reset()
method,
so maybe @Thisch had a reason to use this name.
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.
Oh I didn't notice that, never mind then.
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.
Note that the docstring of LogCaptureFixure.clear starts with "reset" ;) There is no specific reson why I chose "reset" in my initial commit, though.
d256b09
to
02bec7a
Compare
I didn't see any other files in |
Yep is just that we just had a release last week and your PR is the first one since then to land on Thanks, LGTM! 👍 |
👍 thanks |
Fix #3297 where
caplog.clear()
did not clear text, just records.Fix by @Thisch that re-installs a new
StringIO
on the handler as suggested in https://stackoverflow.com/questions/4330812/how-do-i-clear-a-stringio-object#4330829reset()
method on the handler, used also oncaplog
construction .