summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2016-08-17 13:20:01 -0700
committerTim Graham <timograham@gmail.com>2016-08-17 16:20:01 -0400
commit49fcbe73c5004fd576b2aaed2c20b798cc878824 (patch)
tree8932d992bc8200f19e2baa70d9509be5e6105739
parente76981b43325da60b8a7475661df6cbfa7fda37e (diff)
Fixed #27078 -- Simplified "if" logic in SQLite's _get_test_db_name().
-rw-r--r--django/db/backends/sqlite3/creation.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/django/db/backends/sqlite3/creation.py b/django/db/backends/sqlite3/creation.py
index 9f1598e3ee..26ad0d4f95 100644
--- a/django/db/backends/sqlite3/creation.py
+++ b/django/db/backends/sqlite3/creation.py
@@ -12,17 +12,18 @@ class DatabaseCreation(BaseDatabaseCreation):
def _get_test_db_name(self):
test_database_name = self.connection.settings_dict['TEST']['NAME']
can_share_in_memory_db = self.connection.features.can_share_in_memory_db
- if test_database_name and test_database_name != ':memory:':
- if 'mode=memory' in test_database_name and not can_share_in_memory_db:
- raise ImproperlyConfigured(
- "Using a shared memory database with `mode=memory` in the "
- "database name is not supported in your environment, "
- "use `:memory:` instead."
- )
- return test_database_name
+ if not test_database_name:
+ test_database_name = ':memory:'
if can_share_in_memory_db:
- return 'file:memorydb_%s?mode=memory&cache=shared' % self.connection.alias
- return ':memory:'
+ 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(
+ "Using a shared memory database with `mode=memory` in the "
+ "database name is not supported in your environment, "
+ "use `:memory:` instead."
+ )
+ return test_database_name
def _create_test_db(self, verbosity, autoclobber, keepdb=False):
test_database_name = self._get_test_db_name()