Fixed #27078 -- Simplified "if" logic in SQLite's _get_test_db_name().
This commit is contained in:
parent
e76981b433
commit
49fcbe73c5
|
@ -12,17 +12,18 @@ class DatabaseCreation(BaseDatabaseCreation):
|
||||||
def _get_test_db_name(self):
|
def _get_test_db_name(self):
|
||||||
test_database_name = self.connection.settings_dict['TEST']['NAME']
|
test_database_name = self.connection.settings_dict['TEST']['NAME']
|
||||||
can_share_in_memory_db = self.connection.features.can_share_in_memory_db
|
can_share_in_memory_db = self.connection.features.can_share_in_memory_db
|
||||||
if test_database_name and test_database_name != ':memory:':
|
if not test_database_name:
|
||||||
if 'mode=memory' in test_database_name and not can_share_in_memory_db:
|
test_database_name = ':memory:'
|
||||||
|
if can_share_in_memory_db:
|
||||||
|
if test_database_name == ':memory:':
|
||||||
|
return 'file:memorydb_%s?mode=memory&cache=shared' % self.connection.alias
|
||||||
|
elif 'mode=memory' in test_database_name:
|
||||||
raise ImproperlyConfigured(
|
raise ImproperlyConfigured(
|
||||||
"Using a shared memory database with `mode=memory` in the "
|
"Using a shared memory database with `mode=memory` in the "
|
||||||
"database name is not supported in your environment, "
|
"database name is not supported in your environment, "
|
||||||
"use `:memory:` instead."
|
"use `:memory:` instead."
|
||||||
)
|
)
|
||||||
return test_database_name
|
return test_database_name
|
||||||
if can_share_in_memory_db:
|
|
||||||
return 'file:memorydb_%s?mode=memory&cache=shared' % self.connection.alias
|
|
||||||
return ':memory:'
|
|
||||||
|
|
||||||
def _create_test_db(self, verbosity, autoclobber, keepdb=False):
|
def _create_test_db(self, verbosity, autoclobber, keepdb=False):
|
||||||
test_database_name = self._get_test_db_name()
|
test_database_name = self._get_test_db_name()
|
||||||
|
|
Loading…
Reference in New Issue