MCPcopy Index your code
hub / github.com/python/cpython / test_utcnow

Method test_utcnow

Lib/test/datetimetester.py:2995–3010  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2993 self.assertEqual(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000))
2994
2995 def test_utcnow(self):
2996 import time
2997
2998 # Call it a success if utcnow() and utcfromtimestamp() are within
2999 # a second of each other.
3000 tolerance = timedelta(seconds=1)
3001 for dummy in range(3):
3002 with self.assertWarns(DeprecationWarning):
3003 from_now = self.theclass.utcnow()
3004
3005 with self.assertWarns(DeprecationWarning):
3006 from_timestamp = self.theclass.utcfromtimestamp(time.time())
3007 if abs(from_timestamp - from_now) <= tolerance:
3008 break
3009 # Else try again a few times.
3010 self.assertLessEqual(abs(from_timestamp - from_now), tolerance)
3011
3012 def test_strptime(self):
3013 string = '2004-12-01 13:02:47.197'

Callers

nothing calls this directly

Calls 7

timedeltaClass · 0.90
absFunction · 0.85
assertWarnsMethod · 0.80
utcnowMethod · 0.80
assertLessEqualMethod · 0.80
utcfromtimestampMethod · 0.45
timeMethod · 0.45

Tested by

no test coverage detected