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

Method test_check_tzinfo

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

Source from the content-addressed store, hash-verified

7014 self.assertFalse(is_timedelta(arg, exact))
7015
7016 def test_check_tzinfo(self):
7017 class TZInfoSubclass(tzinfo):
7018 pass
7019
7020 tzi = tzinfo()
7021 tzis = TZInfoSubclass()
7022 tz = timezone(timedelta(hours=-5))
7023
7024 is_tzinfo = _testcapi.datetime_check_tzinfo
7025
7026 # Check the ones that should be valid
7027 self.assertTrue(is_tzinfo(tzi))
7028 self.assertTrue(is_tzinfo(tz))
7029 self.assertTrue(is_tzinfo(tzis))
7030 self.assertTrue(is_tzinfo(tzi, True))
7031
7032 # Check that the subclasses do not match exactly
7033 self.assertFalse(is_tzinfo(tz, True))
7034 self.assertFalse(is_tzinfo(tzis, True))
7035
7036 # Check that various other things are not tzinfos
7037 args = [tuple(), list(), 1, '2011-01-01',
7038 date(2011, 1, 1), datetime(2011, 1, 1)]
7039
7040 for arg in args:
7041 for exact in (True, False):
7042 with self.subTest(arg=arg, exact=exact):
7043 self.assertFalse(is_tzinfo(arg, exact))
7044
7045 def test_date_from_date(self):
7046 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.80

Tested by

no test coverage detected