diff options
Diffstat (limited to 'tests/backends/sqlite/tests.py')
| -rw-r--r-- | tests/backends/sqlite/tests.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/backends/sqlite/tests.py b/tests/backends/sqlite/tests.py index 42fee432f9..91dd83f134 100644 --- a/tests/backends/sqlite/tests.py +++ b/tests/backends/sqlite/tests.py @@ -116,6 +116,29 @@ class Tests(TestCase): connection.check_database_version_supported() self.assertTrue(mocked_get_database_version.called) + def test_init_command(self): + settings_dict = { + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": ":memory:", + "OPTIONS": { + "init_command": "PRAGMA synchronous=3; PRAGMA cache_size=2000;", + }, + } + } + connections = ConnectionHandler(settings_dict) + connections["default"].ensure_connection() + try: + with connections["default"].cursor() as cursor: + cursor.execute("PRAGMA synchronous") + value = cursor.fetchone()[0] + self.assertEqual(value, 3) + cursor.execute("PRAGMA cache_size") + value = cursor.fetchone()[0] + self.assertEqual(value, 2000) + finally: + connections["default"].close() + @unittest.skipUnless(connection.vendor == "sqlite", "SQLite tests") @isolate_apps("backends") |
