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

Method test_subclass_datetimetz

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

Source from the content-addressed store, hash-verified

5539 self.assertTrue(t1 < t2) # t1's offset counter still going up
5540
5541 def test_subclass_datetimetz(self):
5542
5543 class C(self.theclass):
5544 theAnswer = 42
5545
5546 def __new__(cls, *args, **kws):
5547 temp = kws.copy()
5548 extra = temp.pop('extra')
5549 result = self.theclass.__new__(cls, *args, **temp)
5550 result.extra = extra
5551 return result
5552
5553 def newmeth(self, start):
5554 return start + self.hour + self.year
5555
5556 args = 2002, 12, 31, 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
5557
5558 dt1 = self.theclass(*args)
5559 dt2 = C(*args, **{'extra': 7})
5560
5561 self.assertEqual(dt2.__class__, C)
5562 self.assertEqual(dt2.theAnswer, 42)
5563 self.assertEqual(dt2.extra, 7)
5564 self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
5565 self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.year - 7)
5566
5567# Pain to set up DST-aware tzinfo classes.
5568

Callers

nothing calls this directly

Calls 5

newmethMethod · 0.95
FixedOffsetClass · 0.70
CClass · 0.70
assertEqualMethod · 0.45
utcoffsetMethod · 0.45

Tested by

no test coverage detected