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

Method test_argument_passing

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

Source from the content-addressed store, hash-verified

4374class TZInfoBase:
4375
4376 def test_argument_passing(self):
4377 cls = self.theclass
4378 # A datetime passes itself on, a time passes None.
4379 class introspective(tzinfo):
4380 def tzname(self, dt): return dt and "real" or "none"
4381 def utcoffset(self, dt):
4382 return timedelta(minutes = dt and 42 or -42)
4383 dst = utcoffset
4384
4385 obj = cls(1, 2, 3, tzinfo=introspective())
4386
4387 expected = cls is time and "none" or "real"
4388 self.assertEqual(obj.tzname(), expected)
4389
4390 expected = timedelta(minutes=(cls is time and -42 or 42))
4391 self.assertEqual(obj.utcoffset(), expected)
4392 self.assertEqual(obj.dst(), expected)
4393
4394 def test_bad_tzinfo_classes(self):
4395 cls = self.theclass

Callers

nothing calls this directly

Calls 7

timedeltaClass · 0.90
introspectiveClass · 0.85
clsClass · 0.50
assertEqualMethod · 0.45
tznameMethod · 0.45
utcoffsetMethod · 0.45
dstMethod · 0.45

Tested by

no test coverage detected