MCPcopy
hub / github.com/django/django / test_expiration

Method test_expiration

tests/cache/tests.py:503–514  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

501 self.assertEqual(expensive_calculation.num_runs, runs_before_cache_read)
502
503 def test_expiration(self):
504 # Cache values can be set to expire
505 cache.set("expire1", "very quickly", 1)
506 cache.set("expire2", "very quickly", 1)
507 cache.set("expire3", "very quickly", 1)
508
509 time.sleep(2)
510 self.assertIsNone(cache.get("expire1"))
511
512 self.assertIs(cache.add("expire2", "newvalue"), True)
513 self.assertEqual(cache.get("expire2"), "newvalue")
514 self.assertIs(cache.has_key("expire3"), False)
515
516 @retry()
517 def test_touch(self):

Callers

nothing calls this directly

Calls 5

sleepMethod · 0.80
setMethod · 0.45
getMethod · 0.45
addMethod · 0.45
has_keyMethod · 0.45

Tested by

no test coverage detected