From 9211919c27a345c0ffb27c4302f6364355595abf Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Tue, 7 May 2019 12:33:28 +0200 Subject: [PATCH] WIP: call teardown_database always (with keepdb) It restores the DB name for example - not sure if this is done differently already. --- pytest_django/fixtures.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pytest_django/fixtures.py b/pytest_django/fixtures.py index 0c8606f26..9b143f0b0 100644 --- a/pytest_django/fixtures.py +++ b/pytest_django/fixtures.py @@ -111,7 +111,11 @@ def django_db_setup( def teardown_database(): with django_db_blocker.unblock(): try: - teardown_databases(db_cfg, verbosity=request.config.option.verbose) + teardown_databases( + db_cfg, + verbosity=request.config.option.verbose, + keepdb=django_db_keepdb, + ) except Exception as exc: request.node.warn( pytest.PytestWarning( @@ -119,8 +123,7 @@ def teardown_database(): ) ) - if not django_db_keepdb: - request.addfinalizer(teardown_database) + request.addfinalizer(teardown_database) def _django_db_fixture_helper(