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

Method test_subclass_date

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

Source from the content-addressed store, hash-verified

941 self.assertEqual(t4.as_hours(), -1)
942
943 def test_subclass_date(self):
944 class DateSubclass(date):
945 pass
946
947 d1 = DateSubclass(2018, 1, 5)
948 td = timedelta(days=1)
949
950 tests = [
951 ('add', lambda d, t: d + t, DateSubclass(2018, 1, 6)),
952 ('radd', lambda d, t: t + d, DateSubclass(2018, 1, 6)),
953 ('sub', lambda d, t: d - t, DateSubclass(2018, 1, 4)),
954 ]
955
956 for name, func, expected in tests:
957 with self.subTest(name):
958 act = func(d1, td)
959 self.assertEqual(act, expected)
960 self.assertIsInstance(act, DateSubclass)
961
962 def test_subclass_datetime(self):
963 class DateTimeSubclass(datetime):

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected