MCPcopy
hub / github.com/django/django / test_zero_timeout

Method test_zero_timeout

tests/cache/tests.py:666–682  ·  view source on GitHub ↗

Passing in zero into timeout results in a value that is not cached

(self)

Source from the content-addressed store, hash-verified

664 self.assertEqual(cache.get("key5"), "belgian fries")
665
666 def test_zero_timeout(self):
667 """
668 Passing in zero into timeout results in a value that is not cached
669 """
670 cache.set("key1", "eggs", 0)
671 self.assertIsNone(cache.get("key1"))
672
673 self.assertIs(cache.add("key2", "ham", 0), True)
674 self.assertIsNone(cache.get("key2"))
675
676 cache.set_many({"key3": "sausage", "key4": "lobster bisque"}, 0)
677 self.assertIsNone(cache.get("key3"))
678 self.assertIsNone(cache.get("key4"))
679
680 cache.set("key5", "belgian fries", timeout=5)
681 self.assertIs(cache.touch("key5", timeout=0), True)
682 self.assertIsNone(cache.get("key5"))
683
684 def test_float_timeout(self):
685 # Make sure a timeout given as a float doesn't crash anything.

Callers

nothing calls this directly

Calls 5

setMethod · 0.45
getMethod · 0.45
addMethod · 0.45
set_manyMethod · 0.45
touchMethod · 0.45

Tested by

no test coverage detected