[Django] #25504: Django test teardown fails when there is no default database

44 views
Skip to first unread message

Django

unread,
Oct 5, 2015, 11:05:40 AM10/5/15
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-------------------------------+--------------------
Reporter: Sjord | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.9a1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
When running a Django TestCase with an empty dict as default database, I
get an error. This is similar to
[https://code.djangoproject.com/ticket/24394 #24394], but happens at
teardown of the test.

I installed Django 1.9a1, created a new project using `django-admin
startproject bug`. I edited my settings.py to read this:


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


And I added an empty testcase that uses the Django TestCase class like
this:

{{{
from django.test.testcases import TestCase

class Test(TestCase):
def test_nothing(self):
pass
}}}

Then, when I do `./manage test` I get the following stacktrace:

{{{
Traceback (most recent call last):
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/test/testcases.py", line 217, in __call__
self._post_teardown()
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/test/testcases.py", line 919, in _post_teardown
self._fixture_teardown()
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/test/testcases.py", line 1072, in _fixture_teardown
return super(TestCase, self)._fixture_teardown()
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/test/testcases.py", line 955, in _fixture_teardown
inhibit_post_migrate=inhibit_post_migrate)
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 119, in call_command
return command.execute(*args, **defaults)
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/core/management/commands/flush.py", line 49, in handle
allow_cascade=allow_cascade)
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/core/management/sql.py", line 15, in sql_flush
tables =
connection.introspection.django_table_names(only_existing=True,
include_views=False)
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/db/backends/base/introspection.py", line 86, in
django_table_names
existing_tables = self.table_names(include_views=include_views)
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/db/backends/base/introspection.py", line 56, in
table_names
with self.connection.cursor() as cursor:
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/db/backends/base/base.py", line 233, in cursor
cursor = self.make_cursor(self._cursor())
File "/home/sjoerd/.virtualenvs/b24394/local/lib/python2.7/site-
packages/django/db/backends/dummy/base.py", line 21, in complain
raise ImproperlyConfigured("settings.DATABASES is improperly
configured. "
ImproperlyConfigured: settings.DATABASES is improperly configured. Please
supply the ENGINE value. Check settings documentation for more details.
}}}

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

Django

unread,
Oct 5, 2015, 5:46:49 PM10/5/15
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-----------------------------------+------------------------------------
Reporter: Sjord | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.9a1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* needs_better_patch: => 0
* component: Uncategorized => Testing framework
* needs_tests: => 0
* needs_docs: => 0
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


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

Django

unread,
Nov 7, 2015, 5:33:14 AM11/7/15
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-----------------------------------+------------------------------------
Reporter: Sjord | Owner: mihaicc
Type: Bug | Status: assigned

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

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

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


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

Django

unread,
Nov 7, 2015, 11:30:21 AM11/7/15
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-----------------------------------+------------------------------------
Reporter: Sjord | Owner: mihaicc
Type: Bug | Status: assigned
Component: Testing framework | Version: 1.9a1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by mihaicc):

I didn't manage to finish this ticket.

Progress so far:
- have 2 tests (one broader and one narrower to the exception)
- found out this happens for fixtures setup as well
- debated two solutions with Michael Manfre and Tim and will follow soon
with a pull request

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

Django

unread,
Dec 5, 2015, 5:02:32 PM12/5/15
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-----------------------------------+------------------------------------
Reporter: Sjord | Owner: mihaicc
Type: Bug | Status: assigned
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* version: 1.9a1 => 1.9


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

Django

unread,
Sep 28, 2016, 12:20:09 PM9/28/16
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-----------------------------------+------------------------------------
Reporter: Sjoerd Langkemper | Owner: mihaicc

Type: Bug | Status: assigned
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by Tim Graham):

mihaicc, can you share a link to your work so others could use it as a
starting point if you're unable to finish it?

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

Django

unread,
Jan 15, 2018, 10:43:16 AM1/15/18
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-----------------------------------+------------------------------------
Reporter: Sjoerd Langkemper | Owner: (none)
Type: Bug | Status: new

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

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

* owner: mihaicc => (none)
* status: assigned => new


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

Django

unread,
Nov 14, 2023, 9:58:50 AM11/14/23
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-----------------------------------+------------------------------------
Reporter: Sjoerd Langkemper | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by bcail):

There seems to be a conflict in the documentation for this issue of a
blank 'default' database. In the
[https://docs.djangoproject.com/en/4.2/ref/settings/#databases Settings
docs], it says: "The DATABASES setting must configure a default database;
any number of additional databases may also be specified."

But the [https://docs.djangoproject.com/en/4.2/topics/db/multi-db
/#defining-your-databases multiple database setup docs] still explicitly
gives the example of leaving the 'default' database blank.

What's the path forward on this?

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

Django

unread,
Dec 7, 2023, 2:50:31 PM12/7/23
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-----------------------------------+------------------------------------
Reporter: Sjoerd Langkemper | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by bcail):

Forum thread: https://forum.djangoproject.com/t/ticket-25504-multiple-
databases-with-no-default/25376

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

Django

unread,
Nov 20, 2025, 8:28:32 PM (9 days ago) Nov 20
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-----------------------------------+------------------------------------
Reporter: Sjoerd Langkemper | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+------------------------------------
Comment (by Hwayoung Cha):

Hi! It appears that no one is currently working on this issue, so I’ll go
ahead and assign it to myself.
--
Ticket URL: <https://code.djangoproject.com/ticket/25504#comment:9>

Django

unread,
Nov 20, 2025, 8:29:01 PM (9 days ago) Nov 20
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-------------------------------------+-------------------------------------
Reporter: Sjoerd Langkemper | Owner: Hwayoung
| Cha
Type: Bug | Status: assigned
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hwayoung Cha):

* has_patch: 0 => 1
* owner: (none) => Hwayoung Cha
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/25504#comment:10>

Django

unread,
Nov 25, 2025, 5:06:04 AM (5 days ago) Nov 25
to django-...@googlegroups.com
#25504: Django test teardown fails when there is no default database
-------------------------------------+-------------------------------------
Reporter: Sjoerd Langkemper | Owner: Hwayoung
| Cha
Type: Bug | Status: assigned
Component: Testing framework | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* has_patch: 1 => 0

Comment:

There is no patch submitted for this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/25504#comment:11>
Reply all
Reply to author
Forward
0 new messages