Skip to content

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

Closed
@dionhaefner

Description

@dionhaefner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions