Why won't pytest use pyproject.toml for this deprecation warning
Asked Answered
S

1

15

I have a django project managed with pytest and poetry.

I'd like to put my pytest config into the pyproject.toml file, so I added:

[tool.pytest]
filterwarnings = ["ignore::django.utils.deprecation.RemovedInDjango40Warning", "ignore::django.utils.deprecation.RemovedInDjango41Warning"]

However, this made no difference - the warning weren't filtered.

If I add a pytest.ini file containing the following...

[pytest]
filterwarnings =
    ignore::django.utils.deprecation.RemovedInDjango40Warning
    ignore::django.utils.deprecation.RemovedInDjango41Warning

... it works just fine.

What's wrong with my pyproject.toml, or my pytest configuration, that it's not being picked up?

Sarchet answered 3/7, 2021 at 12:43 Comment(0)
F
35

As per pytest's docs the section name should be [tool.pytest.ini_options]

Felly answered 3/7, 2021 at 12:45 Comment(1)
Brilliant, thank you! I was working off a github issue form when pyproject support was initially implemented, it must have been from before they reserved the [tool.pytest] for future use. Thanks again!Sarchet

© 2022 - 2024 — McMap. All rights reserved.