MCPcopy
hub / github.com/django/django / _perform_cull_test

Method _perform_cull_test

tests/cache/tests.py:689–704  ·  view source on GitHub ↗
(self, cull_cache_name, initial_count, final_count)

Source from the content-addressed store, hash-verified

687 self.assertEqual(cache.get("key1"), "spam")
688
689 def _perform_cull_test(self, cull_cache_name, initial_count, final_count):
690 try:
691 cull_cache = caches[cull_cache_name]
692 except InvalidCacheBackendError:
693 self.skipTest("Culling isn't implemented.")
694
695 # Create initial cache key entries. This will overflow the cache,
696 # causing a cull.
697 for i in range(1, initial_count):
698 cull_cache.set("cull%d" % i, "value", 1000)
699 count = 0
700 # Count how many keys are left in the cache.
701 for i in range(1, initial_count):
702 if cull_cache.has_key("cull%d" % i):
703 count += 1
704 self.assertEqual(count, final_count)
705
706 def test_cull(self):
707 self._perform_cull_test("cull", 50, 29)

Callers 3

test_cullMethod · 0.95
test_zero_cullMethod · 0.95
test_zero_cullMethod · 0.80

Calls 2

setMethod · 0.45
has_keyMethod · 0.45

Tested by

no test coverage detected