summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2012-07-21 20:16:47 -0300
committerRamiro Morales <cramm0@gmail.com>2012-07-22 11:06:16 -0300
commitc2ff027861dcbdd0c6ac82eb6e7f74455499c4e6 (patch)
tree567c6f9be6d176e3cc4bd785db9ad48c86db11f1
parent8ba78a0daf037b93194ccd1eb84614d72c7482a9 (diff)
[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 ea667ee3aeed33bce1dd681d9c0ea42f9926db5a from master.
-rw-r--r--django/test/testcases.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py
index b5e1dc0418..1f451877ac 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -1143,4 +1143,11 @@ class LiveServerTestCase(TransactionTestCase):
if hasattr(cls, 'server_thread'):
# Terminate the live server's thread
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()