diff options
author | Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com> | 2015-10-05 19:25:06 +0200 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2015-10-06 12:32:05 -0400 |
commit | 3543fec3b739864c52de0a116dde3b0e5e885799 (patch) | |
tree | a0b0f470e39b6d9e4f39a70528588858a4e4e585 /tests | |
parent | 6afa6818fcf25665bbf61f0921c8c8c6fa8f223e (diff) | |
download | django-3543fec3b739864c52de0a116dde3b0e5e885799.tar.gz |
Refs #12118 -- Allowed "mode=memory" in SQLite test database names.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/backends/tests.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/backends/tests.py b/tests/backends/tests.py index 39a2654a77..6237e860fb 100644 --- a/tests/backends/tests.py +++ b/tests/backends/tests.py @@ -142,6 +142,30 @@ class SQLiteTests(TestCase): models.Item.objects.all().aggregate, **{'complex': aggregate('last_modified') + aggregate('last_modified')}) + def test_memory_db_test_name(self): + """ + A named in-memory db should be allowed where supported. + """ + from django.db.backends.sqlite3.base import DatabaseWrapper + settings_dict = { + 'TEST': { + 'NAME': 'file:memorydb_test?mode=memory&cache=shared', + } + } + wrapper = DatabaseWrapper(settings_dict) + creation = wrapper.creation + if creation.connection.features.can_share_in_memory_db: + expected = creation.connection.settings_dict['TEST']['NAME'] + self.assertEqual(creation._get_test_db_name(), expected) + else: + msg = ( + "Using a shared memory database with `mode=memory` in the " + "database name is not supported in your environment, " + "use `:memory:` instead." + ) + with self.assertRaisesMessage(ImproperlyConfigured, msg): + creation._get_test_db_name() + @unittest.skipUnless(connection.vendor == 'postgresql', "Test only for PostgreSQL") class PostgreSQLTests(TestCase): |