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

Method test_constructor

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

Source from the content-addressed store, hash-verified

284 self.assertEqual(timezone.max.utcoffset(None), limit)
285
286 def test_constructor(self):
287 self.assertIs(timezone.utc, timezone(timedelta(0)))
288 self.assertIsNot(timezone.utc, timezone(timedelta(0), 'UTC'))
289 self.assertEqual(timezone.utc, timezone(timedelta(0), 'UTC'))
290 for subminute in [timedelta(microseconds=1), timedelta(seconds=1)]:
291 tz = timezone(subminute)
292 self.assertNotEqual(tz.utcoffset(None) % timedelta(minutes=1), 0)
293 # invalid offsets
294 for invalid in [timedelta(1, 1), timedelta(1)]:
295 self.assertRaises(ValueError, timezone, invalid)
296 self.assertRaises(ValueError, timezone, -invalid)
297
298 with self.assertRaises(TypeError): timezone(None)
299 with self.assertRaises(TypeError): timezone(42)
300 with self.assertRaises(TypeError): timezone(ZERO, None)
301 with self.assertRaises(TypeError): timezone(ZERO, 42)
302 with self.assertRaises(TypeError): timezone(ZERO, 'ABC', 'extra')
303
304 def test_inheritance(self):
305 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