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

Method test_subclass_datetime

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

Source from the content-addressed store, hash-verified

960 self.assertIsInstance(act, DateSubclass)
961
962 def test_subclass_datetime(self):
963 class DateTimeSubclass(datetime):
964 pass
965
966 d1 = DateTimeSubclass(2018, 1, 5, 12, 30)
967 td = timedelta(days=1, minutes=30)
968
969 tests = [
970 ('add', lambda d, t: d + t, DateTimeSubclass(2018, 1, 6, 13)),
971 ('radd', lambda d, t: t + d, DateTimeSubclass(2018, 1, 6, 13)),
972 ('sub', lambda d, t: d - t, DateTimeSubclass(2018, 1, 4, 12)),
973 ]
974
975 for name, func, expected in tests:
976 with self.subTest(name):
977 act = func(d1, td)
978 self.assertEqual(act, expected)
979 self.assertIsInstance(act, DateTimeSubclass)
980
981 def test_division(self):
982 t = timedelta(hours=1, minutes=24, seconds=19)

Callers

nothing calls this directly

Calls 6

timedeltaClass · 0.90
assertIsInstanceMethod · 0.80
DateTimeSubclassClass · 0.70
funcFunction · 0.70
subTestMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected