MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_utcnow

Method test_utcnow

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

Source from the content-addressed store, hash-verified

2854 self.assertEqual(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000))
2855
2856 def test_utcnow(self):
2857 import time
2858
2859 # Call it a success if utcnow() and utcfromtimestamp() are within
2860 # a second of each other.
2861 tolerance = timedelta(seconds=1)
2862 for dummy in range(3):
2863 with self.assertWarns(DeprecationWarning):
2864 from_now = self.theclass.utcnow()
2865
2866 with self.assertWarns(DeprecationWarning):
2867 from_timestamp = self.theclass.utcfromtimestamp(time.time())
2868 if abs(from_timestamp - from_now) <= tolerance:
2869 break
2870 # Else try again a few times.
2871 self.assertLessEqual(abs(from_timestamp - from_now), tolerance)
2872
2873 def test_strptime(self):
2874 string = '2004-12-01 13:02:47.197'

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected