MCPcopy
hub / github.com/django/django / test_forever_timeout

Method test_forever_timeout

tests/cache/tests.py:645–664  ·  view source on GitHub ↗

Passing in None into timeout results in a value that is cached forever

(self)

Source from the content-addressed store, hash-verified

643
644 @retry()
645 def test_forever_timeout(self):
646 """
647 Passing in None into timeout results in a value that is cached forever
648 """
649 cache.set("key1", "eggs", None)
650 self.assertEqual(cache.get("key1"), "eggs")
651
652 self.assertIs(cache.add("key2", "ham", None), True)
653 self.assertEqual(cache.get("key2"), "ham")
654 self.assertIs(cache.add("key1", "new eggs", None), False)
655 self.assertEqual(cache.get("key1"), "eggs")
656
657 cache.set_many({"key3": "sausage", "key4": "lobster bisque"}, None)
658 self.assertEqual(cache.get("key3"), "sausage")
659 self.assertEqual(cache.get("key4"), "lobster bisque")
660
661 cache.set("key5", "belgian fries", timeout=1)
662 self.assertIs(cache.touch("key5", timeout=None), True)
663 time.sleep(2)
664 self.assertEqual(cache.get("key5"), "belgian fries")
665
666 def test_zero_timeout(self):
667 """

Callers

nothing calls this directly

Calls 6

sleepMethod · 0.80
setMethod · 0.45
getMethod · 0.45
addMethod · 0.45
set_manyMethod · 0.45
touchMethod · 0.45

Tested by

no test coverage detected