pytest-dev / pytest-dev/pytest-django
django_db_modify_db_settings fixture does nothing by default
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 367
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the django_db_modify_db_settings fixture and its _set_suffix_to_test_databases path, using the reported custom django_db_setup example without xdist or tox. Reproduce the case and verify that settings.DATABASES['default']['TEST']['NAME'] receives the expected test database name by default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- database, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100