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

Method test_constructor

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

Source from the content-addressed store, hash-verified

289 self.assertEqual(timezone.max.utcoffset(None), limit)
290
291 def test_constructor(self):
292 self.assertIs(timezone.utc, timezone(timedelta(0)))
293 self.assertIsNot(timezone.utc, timezone(timedelta(0), 'UTC'))
294 self.assertEqual(timezone.utc, timezone(timedelta(0), 'UTC'))
295 for subminute in [timedelta(microseconds=1), timedelta(seconds=1)]:
296 tz = timezone(subminute)
297 self.assertNotEqual(tz.utcoffset(None) % timedelta(minutes=1), 0)
298 # invalid offsets
299 for invalid in [timedelta(1, 1), timedelta(1)]:
300 self.assertRaises(ValueError, timezone, invalid)
301 self.assertRaises(ValueError, timezone, -invalid)
302
303 with self.assertRaises(TypeError): timezone(None)
304 with self.assertRaises(TypeError): timezone(42)
305 with self.assertRaises(TypeError): timezone(ZERO, None)
306 with self.assertRaises(TypeError): timezone(ZERO, 42)
307 with self.assertRaises(TypeError): timezone(ZERO, 'ABC', 'extra')
308
309 def test_inheritance(self):
310 self.assertIsInstance(timezone.utc, tzinfo)

Callers

nothing calls this directly

Calls 8

timezoneClass · 0.90
timedeltaClass · 0.90
assertIsNotMethod · 0.80
assertNotEqualMethod · 0.80
assertIsMethod · 0.45
assertEqualMethod · 0.45
utcoffsetMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected