pytest-dev / pytest-dev/pytest-django
Fixture django_db_setup stopped working when upgrading from 4.6 to 4.7
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 367
- PR merge metrics
- No merged PRs in 30d
Description
I've been using a custom django_db_setup fixture which has worked for years. After upgrading from 4.6 to 4.7 this suddenly doesn't work anymore, resulting in the following error:
RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it.
This might be a bug. Anybody any idea how to fix this from 4.7?
The fixture is something like this:
@pytest.yield_fixture(scope="session", autouse=True)
def django_db_setup(django_db_blocker):
with django_db_blocker.unblock():
# Code that requires DB access and populates data required for all tests.
Model.objects.create()
# At this point the DB setup for the tests is complete
yield
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 with the custom session-scoped django_db_setup fixture shown in the report and compare its behavior on versions 4.6 and 4.7, focusing on django_db_blocker.unblock(). Confirm the expected database-access behavior during setup, then capture a regression test or migration guidance once the cause is established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- databases, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100