11

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?

thclark
  • 4,784
  • 3
  • 39
  • 65

1 Answers1

27

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

DeepSpace
  • 78,697
  • 11
  • 109
  • 154
  • 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! – thclark Jul 03 '21 at 13:16