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

Method test_datetime_from_timestamp

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

Source from the content-addressed store, hash-verified

7333 self.assertEqual(d, date(1995, 4, 12))
7334
7335 def test_datetime_from_timestamp(self):
7336 cases = [
7337 ((1995, 4, 12), None, False),
7338 ((1995, 4, 12), None, True),
7339 ((1995, 4, 12), timezone(timedelta(hours=1)), True),
7340 ((1995, 4, 12, 14, 30), None, False),
7341 ((1995, 4, 12, 14, 30), None, True),
7342 ((1995, 4, 12, 14, 30), timezone(timedelta(hours=1)), True),
7343 ]
7344
7345 from_timestamp = _testcapi.get_datetime_fromtimestamp
7346 for case in cases:
7347 for macro in False, True:
7348 with self.subTest(case=case, macro=macro):
7349 dtup, tzinfo, usetz = case
7350 dt_orig = datetime(*dtup, tzinfo=tzinfo)
7351 ts = int(dt_orig.timestamp())
7352
7353 dt_rt = from_timestamp(ts, tzinfo, usetz, macro)
7354
7355 self.assertEqual(dt_orig, dt_rt)
7356
7357 def test_type_check_in_subinterp(self):
7358 # iOS requires the use of the custom framework loader,

Callers

nothing calls this directly

Calls 6

timezoneClass · 0.90
timedeltaClass · 0.90
datetimeClass · 0.90
timestampMethod · 0.80
subTestMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected