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

Method test_subclass_time

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

Source from the content-addressed store, hash-verified

4150 self.assertEqual(res.fold, fold)
4151
4152 def test_subclass_time(self):
4153
4154 class C(self.theclass):
4155 theAnswer = 42
4156
4157 def __new__(cls, *args, **kws):
4158 temp = kws.copy()
4159 extra = temp.pop('extra')
4160 result = self.theclass.__new__(cls, *args, **temp)
4161 result.extra = extra
4162 return result
4163
4164 def newmeth(self, start):
4165 return start + self.hour + self.second
4166
4167 args = 4, 5, 6
4168
4169 dt1 = self.theclass(*args)
4170 dt2 = C(*args, **{'extra': 7})
4171
4172 self.assertEqual(dt2.__class__, C)
4173 self.assertEqual(dt2.theAnswer, 42)
4174 self.assertEqual(dt2.extra, 7)
4175 self.assertEqual(dt1.isoformat(), dt2.isoformat())
4176 self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
4177
4178 def test_backdoor_resistance(self):
4179 # see TestDate.test_backdoor_resistance().

Callers

nothing calls this directly

Calls 4

newmethMethod · 0.95
CClass · 0.70
assertEqualMethod · 0.45
isoformatMethod · 0.45

Tested by

no test coverage detected