#19031: Using @override_settings doesn't override DATABASES in threads +SQLite
-----------------------------------+--------------------
Reporter: jonash | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------
I'm aware of the fact that SQLite's `:memory:` mode doesn't work with
threads, so I wanted to override `TEST_NAME` using `override_settings` to
make SQLite use a filesystem DB for a single test:
{{{
from django.test import TransactionTestCase
from django.db import models
from django.test.utils import override_settings
from threading import Thread
class OverrideDATABASESTest(TransactionTestCase):
@override_settings(DATABASES={'default': {'BACKEND':
'django.db.backends.sqlite3', 'TEST_NAME': 'test-db'}})
def test_override_DATABASES(self):
t = Thread(target=SomeModel.objects.get)
t.start()
t.join()
}}}
This doesn't work with threads, it fails with a `DatabaseError: no such
table: app_modelname` exception in the thread. The test works if I set
`TEST_NAME` in my `settings.py` though, so this seems like an issue with
`override_settings`.
--
Ticket URL: <https://code.djangoproject.com/ticket/19031>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.