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

Method test_subclass_date

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

Source from the content-addressed store, hash-verified

1888 self.assertEqual(res.extra, 7)
1889
1890 def test_subclass_date(self):
1891
1892 class C(self.theclass):
1893 theAnswer = 42
1894
1895 def __new__(cls, *args, **kws):
1896 temp = kws.copy()
1897 extra = temp.pop('extra')
1898 result = self.theclass.__new__(cls, *args, **temp)
1899 result.extra = extra
1900 return result
1901
1902 def newmeth(self, start):
1903 return start + self.year + self.month
1904
1905 args = 2003, 4, 14
1906
1907 dt1 = self.theclass(*args)
1908 dt2 = C(*args, **{'extra': 7})
1909
1910 self.assertEqual(dt2.__class__, C)
1911 self.assertEqual(dt2.theAnswer, 42)
1912 self.assertEqual(dt2.extra, 7)
1913 self.assertEqual(dt1.toordinal(), dt2.toordinal())
1914 self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month - 7)
1915
1916 def test_subclass_alternate_constructors(self):
1917 # Test that alternate constructors call the constructor

Callers

nothing calls this directly

Calls 4

newmethMethod · 0.95
toordinalMethod · 0.80
CClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected