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

Method test_offset_boundaries

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

Source from the content-addressed store, hash-verified

425 self.assertIs(tz_copy, tz)
426
427 def test_offset_boundaries(self):
428 # Test timedeltas close to the boundaries
429 time_deltas = [
430 timedelta(hours=23, minutes=59),
431 timedelta(hours=23, minutes=59, seconds=59),
432 timedelta(hours=23, minutes=59, seconds=59, microseconds=999999),
433 ]
434 time_deltas.extend([-delta for delta in time_deltas])
435
436 for delta in time_deltas:
437 with self.subTest(test_type='good', delta=delta):
438 timezone(delta)
439
440 # Test timedeltas on and outside the boundaries
441 bad_time_deltas = [
442 timedelta(hours=24),
443 timedelta(hours=24, microseconds=1),
444 ]
445 bad_time_deltas.extend([-delta for delta in bad_time_deltas])
446
447 for delta in bad_time_deltas:
448 with self.subTest(test_type='bad', delta=delta):
449 with self.assertRaises(ValueError):
450 timezone(delta)
451
452 def test_comparison_with_tzinfo(self):
453 # Constructing tzinfo objects directly should not be done by users

Callers

nothing calls this directly

Calls 5

timedeltaClass · 0.90
timezoneClass · 0.90
extendMethod · 0.45
subTestMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected