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

Method test_subclass_timetz

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

Source from the content-addressed store, hash-verified

4830 self.assertIsInstance(tsc_rt, TimeSubclass)
4831
4832 def test_subclass_timetz(self):
4833
4834 class C(self.theclass):
4835 theAnswer = 42
4836
4837 def __new__(cls, *args, **kws):
4838 temp = kws.copy()
4839 extra = temp.pop('extra')
4840 result = self.theclass.__new__(cls, *args, **temp)
4841 result.extra = extra
4842 return result
4843
4844 def newmeth(self, start):
4845 return start + self.hour + self.second
4846
4847 args = 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
4848
4849 dt1 = self.theclass(*args)
4850 dt2 = C(*args, **{'extra': 7})
4851
4852 self.assertEqual(dt2.__class__, C)
4853 self.assertEqual(dt2.theAnswer, 42)
4854 self.assertEqual(dt2.extra, 7)
4855 self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
4856 self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
4857
4858
4859# Testing datetime objects with a non-None tzinfo.

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