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

Teardown drops database if used in combination with live_server

Open jrief opened this issue 2 years ago • 1 comments
trafficstars

In my project, I have an integration test which uses its own prefilled database. This means that in conftest.py, I overwrote this fixture as:

@pytest.fixture
def django_db_setup():
    pass

in order to prevent the database being created. This works fine until I introduced an end-to-end test using the fixture live_server. If this fixture is used, my database is dropped after all tests have finished. It of course is not very pleasant that a database is dropped by a 3rd party library which has been set up by someone else.

I haven't found any possibility to prevent dropping the database, since there is no fixture such as django_db_teardown which could be overridden.

I'm using Django-4.0.10, pytest-7.2.2, pytest-django-4.5.2.

jrief avatar Mar 14 '23 09:03 jrief

Had the same issue, not sure what makes liveserver do so but not the regular testing.

silviogutierrez avatar Feb 15 '25 01:02 silviogutierrez