Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[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 ea667ee from master.
  • Loading branch information...
commit c2ff027861dcbdd0c6ac82eb6e7f74455499c4e6 1 parent 8ba78a0
Ramiro Morales authored July 21, 2012

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. 7  django/test/testcases.py
7  django/test/testcases.py
@@ -1143,4 +1143,11 @@ def tearDownClass(cls):
1143 1143
         if hasattr(cls, 'server_thread'):
1144 1144
             # Terminate the live server's thread
1145 1145
             cls.server_thread.join()
  1146
+
  1147
+        # Restore sqlite connections' non-sharability
  1148
+        for conn in connections.all():
  1149
+            if (conn.settings_dict['ENGINE'] == 'django.db.backends.sqlite3'
  1150
+                and conn.settings_dict['NAME'] == ':memory:'):
  1151
+                conn.allow_thread_sharing = False
  1152
+
1146 1153
         super(LiveServerTestCase, cls).tearDownClass()

0 notes on commit c2ff027

Please sign in to comment.
Something went wrong with that request. Please try again.