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

Method test_check_tzinfo

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

Source from the content-addressed store, hash-verified

7201 self.assertFalse(is_timedelta(arg, exact))
7202
7203 def test_check_tzinfo(self):
7204 class TZInfoSubclass(tzinfo):
7205 pass
7206
7207 tzi = tzinfo()
7208 tzis = TZInfoSubclass()
7209 tz = timezone(timedelta(hours=-5))
7210
7211 is_tzinfo = _testcapi.datetime_check_tzinfo
7212
7213 # Check the ones that should be valid
7214 self.assertTrue(is_tzinfo(tzi))
7215 self.assertTrue(is_tzinfo(tz))
7216 self.assertTrue(is_tzinfo(tzis))
7217 self.assertTrue(is_tzinfo(tzi, True))
7218
7219 # Check that the subclasses do not match exactly
7220 self.assertFalse(is_tzinfo(tz, True))
7221 self.assertFalse(is_tzinfo(tzis, True))
7222
7223 # Check that various other things are not tzinfos
7224 args = [tuple(), list(), 1, '2011-01-01',
7225 date(2011, 1, 1), datetime(2011, 1, 1)]
7226
7227 for arg in args:
7228 for exact in (True, False):
7229 with self.subTest(arg=arg, exact=exact):
7230 self.assertFalse(is_tzinfo(arg, exact))
7231
7232 def test_date_from_date(self):
7233 exp_date = date(1993, 8, 26)

Callers

nothing calls this directly

Calls 10

tzinfoClass · 0.90
timezoneClass · 0.90
timedeltaClass · 0.90
dateClass · 0.90
datetimeClass · 0.90
TZInfoSubclassClass · 0.85
listClass · 0.85
assertTrueMethod · 0.80
assertFalseMethod · 0.80
subTestMethod · 0.45

Tested by

no test coverage detected