django-pytest
django-pytest copied to clipboard
If django-pytest is not installed `@pytest.mark.django_db` is ignored and the main database is used
I realise this is probably because pytest automatically generates these marks, and django-pytest uses them later, but it's quite...surprising to have your main database mutated by the tests :(
I have gotten around this by doing:
import django_pytest as _ # NOTE: Guarantees that pytest-django is installed.
Perhaps having an import alias in django_pytest might solve the problem? Something like:
from django_pytest import mark_django_db