[Django] #24394: Running tests fails when DATABASES['default'] = {}

10 views
Skip to first unread message

Django

unread,
Feb 23, 2015, 2:23:21 AM2/23/15
to django-...@googlegroups.com
#24394: Running tests fails when DATABASES['default'] = {}
-------------------------------+--------------------
Reporter: trecouvr | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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:

1. Create a new project
2. Edit the settings.py this way:

{{{
DATABASES = {
'default': {},
'mysite': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db_mysite.sqlite3'),
}
}
}}}


3. Add a dummy test to yout project, for example:

{{{
from django.test import TestCase


class MyTestCase(TestCase):
def test_pouet(self):
pass
}}}

4. 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/24394>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 23, 2015, 2:26:03 AM2/23/15
to django-...@googlegroups.com
#24394: Running tests fails when DATABASES['default'] = {}
-----------------------------------+--------------------------------------
Reporter: trecouvr | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:
Keywords: test | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Changes (by trecouvr):

* needs_better_patch: => 0
* component: Uncategorized => Testing framework
* needs_tests: => 0
* keywords: => test
* needs_docs: => 0
* type: Uncategorized => Bug


--
Ticket URL: <https://code.djangoproject.com/ticket/24394#comment:1>

Django

unread,
Feb 24, 2015, 8:44:35 AM2/24/15
to django-...@googlegroups.com
#24394: Running tests fails when DATABASES['default'] = {}
-----------------------------------+--------------------------------------
Reporter: trecouvr | Owner: nobody

Type: Bug | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:
Keywords: test | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------

Comment (by knbk):

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 that `DATABASES['default'] = {}` is sufficient, but I
personally have always interpreted this as "`default` requires a valid
database configuration".

--
Ticket URL: <https://code.djangoproject.com/ticket/24394#comment:2>

Django

unread,
Feb 25, 2015, 8:30:58 AM2/25/15
to django-...@googlegroups.com
#24394: Running tests fails when DATABASES['default'] = {}
-----------------------------------+------------------------------------
Reporter: trecouvr | Owner: nobody

Type: Bug | Status: new
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:
Keywords: test | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by knbk):

* stage: Unreviewed => Accepted


Comment:

It is indeed a bug, as the documentation on
[https://docs.djangoproject.com/en/1.7/topics/db/multi-db/#defining-your-
databases multi-db setups] explicitly allows this.

--
Ticket URL: <https://code.djangoproject.com/ticket/24394#comment:3>

Django

unread,
Mar 11, 2015, 3:30:33 PM3/11/15
to django-...@googlegroups.com
#24394: Running tests fails when DATABASES['default'] = {}
-----------------------------------+------------------------------------
Reporter: trecouvr | Owner: akulakov
Type: Bug | Status: assigned

Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:
Keywords: test | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by akulakov):

* status: new => assigned
* owner: nobody => akulakov


--
Ticket URL: <https://code.djangoproject.com/ticket/24394#comment:4>

Django

unread,
Mar 12, 2015, 8:29:17 PM3/12/15
to django-...@googlegroups.com
#24394: Running tests fails when DATABASES['default'] = {}
-----------------------------------+------------------------------------
Reporter: trecouvr | Owner: akulakov
Type: Bug | Status: assigned
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:
Keywords: test | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


Comment:

I've reviewed the [https://github.com/django/django/pull/4308 pull
request].

--
Ticket URL: <https://code.djangoproject.com/ticket/24394#comment:5>

Django

unread,
Mar 21, 2015, 8:50:59 AM3/21/15
to django-...@googlegroups.com
#24394: Running tests fails when DATABASES['default'] = {}
-----------------------------------+------------------------------------
Reporter: trecouvr | Owner: akulakov
Type: Bug | Status: assigned
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution:
Keywords: test | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/24394#comment:6>

Django

unread,
Mar 25, 2015, 6:09:58 PM3/25/15
to django-...@googlegroups.com
#24394: Running tests fails when DATABASES['default'] = {}
-----------------------------------+------------------------------------
Reporter: trecouvr | Owner: akulakov
Type: Bug | Status: closed

Component: Testing framework | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: test | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"e2bfcab065fef4f1c2f32195c74f054991c33151" e2bfcab]:
{{{
#!CommitTicketReference repository=""
revision="e2bfcab065fef4f1c2f32195c74f054991c33151"
Fixed #24394 -- Allowed running tests with empty default dictionary.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24394#comment:7>

Django

unread,
Oct 5, 2015, 11:07:17 AM10/5/15
to django-...@googlegroups.com
#24394: Running tests fails when DATABASES['default'] = {}
-----------------------------------+------------------------------------
Reporter: trecouvr | Owner: akulakov
Type: Bug | Status: closed
Component: Testing framework | Version: 1.7
Severity: Normal | Resolution: fixed
Keywords: test | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------

Comment (by Sjord):

I filed a bug for similar behavior in Django 1.9a1: #25504

--
Ticket URL: <https://code.djangoproject.com/ticket/24394#comment:8>

Reply all
Reply to author
Forward
0 new messages