Skip to content
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

Merged

Conversation

wcooley
Copy link
Contributor

@wcooley wcooley commented Jun 14, 2018

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.

  • Create a new changelog file in the changelog folder, with a name like <ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.
  • Target the features branch for new features and removals/deprecations.
  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Add yourself to AUTHORS in alphabetical order;

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 92.711% when pulling 3615977 on wcooley:feature/3579-caplog-messages into 94c41be on pytest-dev:features.

@@ -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.
Copy link
Member

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]
Copy link
Member

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.

Copy link
Member

@nicoddemus nicoddemus left a 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants