MCPcopy
hub / github.com/django/django / test_init_command

Method test_init_command

tests/backends/sqlite/tests.py:124–145  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

122 self.assertTrue(mocked_get_database_version.called)
123
124 def test_init_command(self):
125 settings_dict = {
126 "default": {
127 "ENGINE": "django.db.backends.sqlite3",
128 "NAME": ":memory:",
129 "OPTIONS": {
130 "init_command": "PRAGMA synchronous=3; PRAGMA cache_size=2000;",
131 },
132 }
133 }
134 connections = ConnectionHandler(settings_dict)
135 connections["default"].ensure_connection()
136 try:
137 with connections["default"].cursor() as cursor:
138 cursor.execute("PRAGMA synchronous")
139 value = cursor.fetchone()[0]
140 self.assertEqual(value, 3)
141 cursor.execute("PRAGMA cache_size")
142 value = cursor.fetchone()[0]
143 self.assertEqual(value, 2000)
144 finally:
145 connections["default"]._close()
146
147
148@unittest.skipUnless(connection.vendor == "sqlite", "SQLite tests")

Callers

nothing calls this directly

Calls 5

ConnectionHandlerClass · 0.90
ensure_connectionMethod · 0.80
cursorMethod · 0.80
executeMethod · 0.45
_closeMethod · 0.45

Tested by

no test coverage detected