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

pytest_sessionfinish cannot access database for cleanup

Open ghost opened this issue 1 year ago • 0 comments
trafficstars

For a given scenario, I need to undo some migrations in order to let the test database be gracefully deleted. One of those migrations creates a replication subscription that avoids the database to be removed. The solution would be to use pytest_sessionfinish hook to undo some migrations and let the teardown process to run gracefully.

However, pytest_django is avoiding the hook to complete, denying database access to it. I cannot find a way around this in order to implement this. The result: the test database need to be removed manually, which breaks the entire deployment automation.

Is there any way of doing it?

ghost avatar May 21 '24 20:05 ghost