pytest-django icon indicating copy to clipboard operation
pytest-django copied to clipboard

Upgrading to pytest 7 breaks django_db mark, and doesn't support pyproject.toml?

Open chris-erickson opened this issue 3 years ago • 1 comments

Once updating to Pytest 7 from 6.2.5, tests that work in pytest < 7 fail with:

RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it.

and to configure the settings file, the only thing that worked was leaving a pytest.ini behind with only this setting (I've migrated the rest to pyproject.toml)

[pytest]
DJANGO_SETTINGS_MODULE = my_app.settings.test

Is this a supported configuration yet, with the settings module in a pyproject.toml?

  • Django 4.0.2
  • Pytest 7.0.1
  • pytest-django 4.5.2

chris-erickson avatar Feb 17 '22 21:02 chris-erickson

You can put this config in your pyproject.toml as well under:

[tool.pytest.ini_options]
DJANGO_SETTINGS_MODULE = "my_app.settings"

HansBambel avatar Aug 29 '22 12:08 HansBambel

@HansBambel got it right!

bluetech avatar Oct 26 '23 20:10 bluetech