Browse files

[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...
1 parent 8ba78a0 commit c2ff027861dcbdd0c6ac82eb6e7f74455499c4e6 @ramiro ramiro committed Jul 21, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 django/test/
@@ -1143,4 +1143,11 @@ def tearDownClass(cls):
if hasattr(cls, 'server_thread'):
# Terminate the live server's thread
+ # 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()

0 comments on commit c2ff027

Please sign in to comment.