pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
11.64k stars 2.58k forks source link

BUG: Fix warning stacklevel #12564

Closed larsoner closed 2 days ago

larsoner commented 3 days ago

Similar to #12014, improves this warning:

  /home/larsoner/python/virtualenvs/base/lib/python3.12/site-packages/_pytest/fixtures.py:1303: PytestRemovedIn9Warning: Marks applied to fixtures have no effect

to become:

  /home/larsoner/python/mne-nirs/mne_nirs/conftest.py:133: PytestRemovedIn9Warning: Marks applied to fixtures have no effect
larsoner commented 3 days ago

py313 failures look unrelated

larsoner commented 2 days ago

I pushed some commits to do a bit of inspect magic to figure out where to emit the warning by traversing the stack until out of the _pytest module. FWIW I adapted it from some code we've used for at least 5 years over in MNE-Python without any real issues. Happy to continue down this path if it seems useful or fine with closing if it seems too magical!

larsoner commented 2 days ago

Yep, too magical -- tests fail because it ends up in the _hypothesis_pytestplugin.py namespace. I'll close!