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

If django-pytest is not installed `@pytest.mark.django_db` is ignored and the main database is used

Open alecthomas opened this issue 12 years ago • 0 comments

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

alecthomas avatar Feb 12 '13 17:02 alecthomas