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

Method test_datetime_from_timestamp

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

Source from the content-addressed store, hash-verified

7146 self.assertEqual(d, date(1995, 4, 12))
7147
7148 def test_datetime_from_timestamp(self):
7149 cases = [
7150 ((1995, 4, 12), None, False),
7151 ((1995, 4, 12), None, True),
7152 ((1995, 4, 12), timezone(timedelta(hours=1)), True),
7153 ((1995, 4, 12, 14, 30), None, False),
7154 ((1995, 4, 12, 14, 30), None, True),
7155 ((1995, 4, 12, 14, 30), timezone(timedelta(hours=1)), True),
7156 ]
7157
7158 from_timestamp = _testcapi.get_datetime_fromtimestamp
7159 for case in cases:
7160 for macro in False, True:
7161 with self.subTest(case=case, macro=macro):
7162 dtup, tzinfo, usetz = case
7163 dt_orig = datetime(*dtup, tzinfo=tzinfo)
7164 ts = int(dt_orig.timestamp())
7165
7166 dt_rt = from_timestamp(ts, tzinfo, usetz, macro)
7167
7168 self.assertEqual(dt_orig, dt_rt)
7169
7170 def test_type_check_in_subinterp(self):
7171 # 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
subTestMethod · 0.80
timestampMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected