#24394 closed Bug (fixed)
Running tests fails when DATABASES['default'] = {}
Reported by: | Thomas Recouvreux | Owned by: | andrei kulakov |
---|---|---|---|
Component: | Testing framework | Version: | 1.7 |
Severity: | Normal | Keywords: | test |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
On Django 1.7.x the management command test
fails when DATABASES['default'] = {}
with AttributeError: 'DatabaseWrapper' object has no attribute 'Database'
.
This failure is also present on 1.7.3 and 1.7.4 version of Django.
To reproduce the problem:
- Create a new project
- Edit the settings.py this way:
DATABASES = { 'default': {}, 'mysite': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db_mysite.sqlite3'), } }
- Add a dummy test to yout project, for example:
from django.test import TestCase class MyTestCase(TestCase): def test_pouet(self): pass
- Run python manage.py test
Problem:
It seems Django instantiate a dummy connector for default
and then calls not implemented methods on this connector.
I am attaching the output log of the command.
Here is a sample project to reproduce the behaviour: https://github.com/trecouvr/test_dj_migrate_174.
Attachments (1)
Change History (9)
by , 10 years ago
comment:1 by , 10 years ago
Component: | Uncategorized → Testing framework |
---|---|
Keywords: | test added |
Type: | Uncategorized → Bug |
comment:2 by , 10 years ago
comment:3 by , 10 years ago
Triage Stage: | Unreviewed → Accepted |
---|
It is indeed a bug, as the documentation on multi-db setups explicitly allows this.
comment:4 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 10 years ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
I've reviewed the pull request.
comment:6 by , 10 years ago
Patch needs improvement: | unset |
---|
I've opened a discussion on this on the mailing list: https://groups.google.com/forum/#!topic/django-developers/VWyP5M7cRyk
I feel this is more a design decision than a bug. The documentation states that
default
is required but not in which way. A strict interpretation would conclude thatDATABASES['default'] = {}
is sufficient, but I personally have always interpreted this as "default
requires a valid database configuration".