Skip to content

Pytest 3.9.1 does not respect filterwarnings in setup.cfg #4180

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
dionhaefner opened this issue Oct 17, 2018 · 2 comments
Closed

Pytest 3.9.1 does not respect filterwarnings in setup.cfg #4180

dionhaefner opened this issue Oct 17, 2018 · 2 comments

Comments

@dionhaefner
Copy link

Today, I noticed that my CI tests were failing with a lot of these errors:

tests/drivers/test_staticmethods.py:5: in <module>
    from shapely.geometry import shape, MultiPolygon
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/shapely/geometry/__init__.py:23: in <module>
    import shapely.speedups
../../../virtualenv/python3.6.3/lib/python3.6/site-packages/shapely/speedups/__init__.py:11: in <module>
    from shapely.speedups import _speedups
shapely/speedups/_speedups.pyx:8: in init shapely.speedups._speedups
    ???
E   ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__

In my setup.cfg, I have configured pytest like this:

[tool:pytest]
addopts =
  -W error
  -v
filterwarnings =
  error
  # ignored by default
  ignore::ImportWarning
  ignore::PendingDeprecationWarning
  # raised by Cython, usually harmless
  ignore:numpy.dtype size changed:RuntimeWarning
  ignore:numpy.ufunc size changed:RuntimeWarning
  # raised by Werkzeug
  ignore:Request.is_xhr is deprecated:DeprecationWarning
  # raised by Moto
  ignore:Flags not at the start of the expression:DeprecationWarning

So the ImportWarning should be ignored due to the filterwarnings specification, but for some reason it is not. The -W error however is read and applied correctly, so the file is found and being parsed.

Downgrading to pytest<3.9 fixed the problem.

@vbarbaresi
Copy link
Member

This is due to this change: #3947
-W error command line option takes precedence over the filters

You can get the old behavior back by removing -W error from the command line, it's duplicated in the filterwarnings

@nicoddemus
Copy link
Member

I think @vbarbaresi nailed it. 👍

I'm closing this for now, feel free to follow up with more questions @dionhaefner.

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

No branches or pull requests

3 participants