MCPcopy Create free account
hub / github.com/rthalley/dnspython / testLRUExpiration

Method testLRUExpiration

tests/test_resolver.py:404–416  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

402 )
403
404 def testLRUExpiration(self):
405 with FakeTime() as fake_time:
406 cache = dns.resolver.LRUCache(4)
407 for i in range(0, 4):
408 name = dns.name.from_text("example%d." % i)
409 answer = FakeAnswer(time.time() + 1)
410 cache.put((name, dns.rdatatype.A, dns.rdataclass.IN), answer)
411 fake_time.sleep(2)
412 for i in range(0, 4):
413 name = dns.name.from_text("example%d." % i)
414 self.assertTrue(
415 cache.get((name, dns.rdatatype.A, dns.rdataclass.IN)) is None
416 )
417
418 def test_cache_flush(self):
419 name1 = dns.name.from_text("name1")

Callers

nothing calls this directly

Calls 7

putMethod · 0.95
getMethod · 0.95
FakeTimeClass · 0.85
FakeAnswerClass · 0.85
timeMethod · 0.80
from_textMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected