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

django_db_modify_db_settings fixture does nothing by default

Open sheats opened this issue 5 years ago • 0 comments
trafficstars

I've implemented django_db_setup to do some fancy DB create/destroy logic and have been requesting django_db_modify_db_settings to give me a test db name at `settings.DATABASES['default']['TEST']['NAME']. When I upgraded from < 3.6 I now get this:

ipdb> pprint(settings.DATABASES['default']['TEST'])
{'CHARSET': None, 'COLLATION': None, 'MIRROR': None, 'NAME': None}

I don't use xdist or tox since it's just a small project. Here's what I'm doing:

@pytest.yield_fixture(scope="session")
def django_db_setup(
    django_db_modify_db_settings,
    django_db_blocker,
    django_db_keepdb,
    django_db_createdb,
):
    from django.conf import settings

    db = settings.DATABASES["default"]
    test_database_name = db["TEST"]["NAME"]

test_database_name used to come in with test_<default name> but now it's set to None.

Looks like #680 created a scenario where if you don't use xdist or tox the django_db_modify_db_settings fixture won't run _set_suffix_to_test_databases.

sheats avatar Jan 31 '20 03:01 sheats