Fixed #12118 -- Added shared cache support to SQLite in-memory testing.

This commit is contained in:
Andriy Sokolovskiy 2014-12-04 01:17:59 +02:00 committed by Tim Graham
parent fca866763a
commit 8c99b7920e
6 changed files with 62 additions and 10 deletions

View file

@ -6,6 +6,7 @@ import copy
import datetime
from decimal import Decimal, Rounded
import re
import sys
import threading
import unittest
import warnings
@ -1201,3 +1202,21 @@ class DBTestSettingsRenamedTests(IgnoreAllDeprecationWarningsMixin, TestCase):
def test_empty_settings(self):
with override_settings(DATABASES=self.db_settings):
self.handler.prepare_test_settings('default')
@unittest.skipUnless(connection.vendor == 'sqlite', 'SQLite specific test.')
@skipUnlessDBFeature('can_share_in_memory_db')
class TestSqliteThreadSharing(TransactionTestCase):
available_apps = ['backends']
def test_database_sharing_in_threads(self):
def create_object():
models.Object.objects.create()
create_object()
thread = threading.Thread(target=create_object)
thread.start()
thread.join()
self.assertEqual(models.Object.objects.count(), 2)