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

Method test_subclass_time

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

Source from the content-addressed store, hash-verified

4333 self.assertEqual(res.fold, fold)
4334
4335 def test_subclass_time(self):
4336
4337 class C(self.theclass):
4338 theAnswer = 42
4339
4340 def __new__(cls, *args, **kws):
4341 temp = kws.copy()
4342 extra = temp.pop('extra')
4343 result = self.theclass.__new__(cls, *args, **temp)
4344 result.extra = extra
4345 return result
4346
4347 def newmeth(self, start):
4348 return start + self.hour + self.second
4349
4350 args = 4, 5, 6
4351
4352 dt1 = self.theclass(*args)
4353 dt2 = C(*args, **{'extra': 7})
4354
4355 self.assertEqual(dt2.__class__, C)
4356 self.assertEqual(dt2.theAnswer, 42)
4357 self.assertEqual(dt2.extra, 7)
4358 self.assertEqual(dt1.isoformat(), dt2.isoformat())
4359 self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
4360
4361 def test_backdoor_resistance(self):
4362 # 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