mirror of
https://github.com/django/django.git
synced 2025-09-23 02:33:31 +00:00
[1.4.x] Made LiveServerTestCase to restore state on exit.
The piece of state is DB connections' allow_thread_sharing attribute
which gets munged when test are run when in-memory SQLite databases.
Thanks Anssi for suggesting the possible root cause and Julien for
implementing the fix.
Backport of ea667ee3ae
from master.
This commit is contained in:
parent
8ba78a0daf
commit
c2ff027861
1 changed files with 7 additions and 0 deletions
|
@ -1143,4 +1143,11 @@ class LiveServerTestCase(TransactionTestCase):
|
||||||
if hasattr(cls, 'server_thread'):
|
if hasattr(cls, 'server_thread'):
|
||||||
# Terminate the live server's thread
|
# Terminate the live server's thread
|
||||||
cls.server_thread.join()
|
cls.server_thread.join()
|
||||||
|
|
||||||
|
# Restore sqlite connections' non-sharability
|
||||||
|
for conn in connections.all():
|
||||||
|
if (conn.settings_dict['ENGINE'] == 'django.db.backends.sqlite3'
|
||||||
|
and conn.settings_dict['NAME'] == ':memory:'):
|
||||||
|
conn.allow_thread_sharing = False
|
||||||
|
|
||||||
super(LiveServerTestCase, cls).tearDownClass()
|
super(LiveServerTestCase, cls).tearDownClass()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue