Ticket #16329: 16329.3.diff
File 16329.3.diff, 3.4 KB (added by , 13 years ago) |
---|
-
django/db/backends/sqlite3/creation.py
diff -r fcf918fa9b40 django/db/backends/sqlite3/creation.py
a b 72 72 73 73 def set_autocommit(self): 74 74 self.connection.connection.isolation_level = None 75 76 def test_db_signature(self): 77 """ 78 Returns a tuple that uniquely identifies a test database. 79 80 This takes into account the special cases of ":memory:" and "" for 81 SQLite since the databases will be distinct despite having the same 82 TEST_NAME. See http://www.sqlite.org/inmemorydb.html 83 """ 84 settings_dict = self.connection.settings_dict 85 test_dbname = self._get_test_db_name() 86 sig = [self.connection.settings_dict['NAME']] 87 if test_dbname == ':memory:': 88 sig.append(self.connection.alias) 89 return tuple(sig) -
tests/regressiontests/test_runner/tests.py
diff -r fcf918fa9b40 tests/regressiontests/test_runner/tests.py
a b 11 11 from django.core.management import call_command 12 12 from django.test import simple 13 13 from django.test.simple import DjangoTestSuiteRunner, get_tests 14 from django.test.testcases import connections_support_transactions 14 15 from django.test.utils import get_warnings_state, restore_warnings_state 15 16 from django.utils import unittest 16 17 from django.utils.importlib import import_module … … 262 263 "Test for #12658 - Tests with ImportError's shouldn't fail silently" 263 264 module = import_module(TEST_APP_ERROR) 264 265 self.assertRaises(ImportError, get_tests, module) 266 267 268 class Sqlite3InMemoryTestDbs(unittest.TestCase): 269 def test_transaction_support(self): 270 """Ticket #16329: sqlite3 in-memory test databases""" 271 from django import db 272 old_db_connections = db.connections 273 for option in ('NAME', 'TEST_NAME'): 274 try: 275 db.connections = db.ConnectionHandler({ 276 'default': { 277 'ENGINE': 'django.db.backends.sqlite3', 278 option: ':memory:', 279 }, 280 'other': { 281 'ENGINE': 'django.db.backends.sqlite3', 282 option: ':memory:', 283 }, 284 }) 285 other = db.connections['other'] 286 self.assertEqual(other.features.supports_transactions, None) 287 DjangoTestSuiteRunner(verbosity=0).setup_databases() 288 # Transaction support should be properly initialised for the 'other' DB 289 self.assertNotEqual( 290 other.features.supports_transactions, 291 None, 292 "DATABASES setting '%s' option set to sqlite3's ':memory:' value causes problems with transaction support detection." % option 293 ) 294 # And all the DBs should report that support transactions 295 self.assertTrue( 296 connections_support_transactions(), 297 "DATABASES setting '%s' option set to sqlite3's ':memory:' value causes problems with transaction support detection." % option 298 ) 299 finally: 300 db.connections = old_db_connections