-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add messages
property to caplog
fixture.
#3585
Add messages
property to caplog
fixture.
#3585
Conversation
@@ -270,6 +270,22 @@ def record_tuples(self): | |||
""" | |||
return [(r.name, r.levelno, r.getMessage()) for r in self.records] | |||
|
|||
@property | |||
def messages(self): | |||
"""Returns a list of format-interpolated log messages. |
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.
awesome docs!
caplog.set_level(logging.INFO) | ||
logger.info("boo %s", "arg") | ||
logger.info("bar %s\nbaz %s", "arg1", "arg2") | ||
assert "boo arg" == caplog.messages[0] |
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.
We usually prefer to invert the order of the operands, but that's OK.
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.
Excellent PR, very complete! Thanks a lot @wcooley!
This is a PR for issue #3579 per @nicoddemus suggestion.
I added the
versionadded
marker for 3.7, assuming that it would not be in before that; I can correct that if needed.It passes all the Travis checks for me except sending to coveralls, presumably because I don't have an account setup with coveralls.
changelog
folder, with a name like<ISSUE NUMBER>.<TYPE>.rst
. See changelog/README.rst for details.features
branch for new features and removals/deprecations.AUTHORS
in alphabetical order;