MCPcopy
hub / github.com/django/django / test_delete_cursor_rowcount

Method test_delete_cursor_rowcount

tests/cache/tests.py:1312–1332  ·  view source on GitHub ↗

The rowcount attribute should not be checked on a closed cursor.

(self)

Source from the content-addressed store, hash-verified

1310 self.assertIn(connection.ops.quote_name("cache_key"), sql)
1311
1312 def test_delete_cursor_rowcount(self):
1313 """
1314 The rowcount attribute should not be checked on a closed cursor.
1315 """
1316
1317 class MockedCursorWrapper(CursorWrapper):
1318 is_closed = False
1319
1320 def close(self):
1321 self.cursor.close()
1322 self.is_closed = True
1323
1324 @property
1325 def rowcount(self):
1326 if self.is_closed:
1327 raise Exception("Cursor is closed.")
1328 return self.cursor.rowcount
1329
1330 cache.set_many({"a": 1, "b": 2})
1331 with mock.patch("django.db.backends.utils.CursorWrapper", MockedCursorWrapper):
1332 self.assertIs(cache.delete("a"), True)
1333
1334 def test_zero_cull(self):
1335 self._perform_cull_test("zero_cull", 50, 18)

Callers

nothing calls this directly

Calls 3

set_manyMethod · 0.45
patchMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected