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

Method test_subclass_timetz

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

Source from the content-addressed store, hash-verified

5017 self.assertIsInstance(tsc_rt, TimeSubclass)
5018
5019 def test_subclass_timetz(self):
5020
5021 class C(self.theclass):
5022 theAnswer = 42
5023
5024 def __new__(cls, *args, **kws):
5025 temp = kws.copy()
5026 extra = temp.pop('extra')
5027 result = self.theclass.__new__(cls, *args, **temp)
5028 result.extra = extra
5029 return result
5030
5031 def newmeth(self, start):
5032 return start + self.hour + self.second
5033
5034 args = 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
5035
5036 dt1 = self.theclass(*args)
5037 dt2 = C(*args, **{'extra': 7})
5038
5039 self.assertEqual(dt2.__class__, C)
5040 self.assertEqual(dt2.theAnswer, 42)
5041 self.assertEqual(dt2.extra, 7)
5042 self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
5043 self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
5044
5045
5046# Testing datetime objects with a non-None tzinfo.

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected