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

deprecated_call context manager captures warnings already raised #2480

Merged

Conversation

nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented Jun 7, 2017

This normalizes the context-manager and function form of deprecated_call by using the exact same implementation.

I also updated the docs to mention the context-manager form first.

Fix #2469

def f():
pass

msg = 'Did not produce DeprecationWarning or PendingDeprecationWarning'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now both context-manager form and function-call form produce the same message; note that previously the context-manager version produced a "DID NOT WARN..." message from pytest.warns instead (see the removed lines just above this one).

I think the vast majority of users just use pytest.deprecated_call to ensure things are issuing deprecation warnings, not actually capturing the AssertionError and checking the message; the latter only makes sense when testing that pytest.deprecated_call works and raises the expected message, which I think it is done only pytest's own test suite.

Having said that, do you feel because of this we should play safe and merge this into features instead?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 92.136% when pulling 620ba59 on nicoddemus:issue-2469-deprecated-call-ctx into 57e2ced on pytest-dev:master.

return WarningsChecker(expected_warning=(DeprecationWarning, PendingDeprecationWarning))
return _DeprecatedCallContext()
else:
with _DeprecatedCallContext():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tracebackhide might be helpfull

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

Fixed.

@RonnyPfannschmidt
Copy link
Member

👍

@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 92.139% when pulling ff8dbd0 on nicoddemus:issue-2469-deprecated-call-ctx into 57e2ced on pytest-dev:master.

@nicoddemus nicoddemus merged commit 22b7701 into pytest-dev:master Jun 22, 2017
@nicoddemus nicoddemus deleted the issue-2469-deprecated-call-ctx branch June 22, 2017 13:53
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.

None yet

3 participants