pytest-django
pytest-django copied to clipboard
Teardown drops database if used in combination with live_server
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.
Had the same issue, not sure what makes liveserver do so but not the regular testing.