MCPcopy
hub / github.com/django/django / test_custom_expiry_timedelta

Method test_custom_expiry_timedelta

tests/sessions_tests/tests.py:422–437  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

420 self.assertEqual(age, 10)
421
422 def test_custom_expiry_timedelta(self):
423 modification = timezone.now()
424
425 # Mock timezone.now, because set_expiry calls it on this code path.
426 original_now = timezone.now
427 try:
428 timezone.now = lambda: modification
429 self.session.set_expiry(timedelta(seconds=10))
430 finally:
431 timezone.now = original_now
432
433 date = self.session.get_expiry_date(modification=modification)
434 self.assertEqual(date, modification + timedelta(seconds=10))
435
436 age = self.session.get_expiry_age(modification=modification)
437 self.assertEqual(age, 10)
438
439 async def test_custom_expiry_timedelta_async(self):
440 modification = timezone.now()

Callers

nothing calls this directly

Calls 4

set_expiryMethod · 0.80
get_expiry_dateMethod · 0.80
get_expiry_ageMethod · 0.80
nowMethod · 0.45

Tested by

no test coverage detected