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

Method test_isoformat_timezone

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

Source from the content-addressed store, hash-verified

2280 self.assertEqual(t.isoformat(), "0002-03-02T00:00:00+00:00:16")
2281
2282 def test_isoformat_timezone(self):
2283 tzoffsets = [
2284 ('05:00', timedelta(hours=5)),
2285 ('02:00', timedelta(hours=2)),
2286 ('06:27', timedelta(hours=6, minutes=27)),
2287 ('12:32:30', timedelta(hours=12, minutes=32, seconds=30)),
2288 ('02:04:09.123456', timedelta(hours=2, minutes=4, seconds=9, microseconds=123456))
2289 ]
2290
2291 tzinfos = [
2292 ('', None),
2293 ('+00:00', timezone.utc),
2294 ('+00:00', timezone(timedelta(0))),
2295 ]
2296
2297 tzinfos += [
2298 (prefix + expected, timezone(sign * td))
2299 for expected, td in tzoffsets
2300 for prefix, sign in [('-', -1), ('+', 1)]
2301 ]
2302
2303 dt_base = self.theclass(2016, 4, 1, 12, 37, 9)
2304 exp_base = '2016-04-01T12:37:09'
2305
2306 for exp_tz, tzi in tzinfos:
2307 dt = dt_base.replace(tzinfo=tzi)
2308 exp = exp_base + exp_tz
2309 with self.subTest(tzi=tzi):
2310 assert dt.isoformat() == exp
2311
2312 def test_format(self):
2313 dt = self.theclass(2007, 9, 10, 4, 5, 1, 123)

Callers

nothing calls this directly

Calls 5

timedeltaClass · 0.90
timezoneClass · 0.90
subTestMethod · 0.80
replaceMethod · 0.45
isoformatMethod · 0.45

Tested by

no test coverage detected