Skip to content

Adjust stacklevel for compat warnings #4236

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

Closed
nicoddemus opened this issue Oct 25, 2018 · 3 comments
Closed

Adjust stacklevel for compat warnings #4236

nicoddemus opened this issue Oct 25, 2018 · 3 comments
Labels
good first issue easy issue that is friendly to new contributor plugin: warnings related to the warnings builtin plugin topic: reporting related to terminal output and user-facing messages and errors

Comments

@nicoddemus
Copy link
Member

Follow up from #4131 (comment).

Currently the warnings show this:

c:\projects\pytest\.tox\py36\lib\site-packages\_pytest\compat.py:321: RemovedInPytest4Warning: usage of Session.Class is deprecated, please use pytest.Class instead
360  return getattr(object, name, default)
361

We need to adjust the warnings stacklevel.

@nicoddemus nicoddemus added topic: reporting related to terminal output and user-facing messages and errors good first issue easy issue that is friendly to new contributor plugin: warnings related to the warnings builtin plugin labels Oct 25, 2018
@pecey
Copy link

pecey commented Oct 28, 2018

I can try and fix this. I would need some help though. If I understand correctly, we need to adjust the stack level for the warnings thrown my the warnings plugin itself.

@RonnyPfannschmidt
Copy link
Member

@pecey unfortunately thats not how it works - the stacklevel is designated for direct usage, here a wrapper is using getattr - so adjusting the stacklevel for that breaks it

we do have a fix to remove the safe_getattr situation by not parsing compat properties as fixture in #4164

@nicoddemus
Copy link
Member Author

@RonnyPfannschmidt is right, the stacklevel is already properly set:

def test(request):
    request.node.session.Class
test-foo.py::test
  C:\pytest\.tmp\test-foo.py:2: RemovedInPytest4Warning: usage of Session.Class is deprecated, please use pytest.Class instead
    request.node.session.Class

We only have to merge #4164 then. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue easy issue that is friendly to new contributor plugin: warnings related to the warnings builtin plugin topic: reporting related to terminal output and user-facing messages and errors
Projects
None yet
Development

No branches or pull requests

3 participants