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

Method test_check_datetime

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

Source from the content-addressed store, hash-verified

7149 self.assertFalse(is_time(arg, exact))
7150
7151 def test_check_datetime(self):
7152 class DateTimeSubclass(datetime):
7153 pass
7154
7155 dt = datetime(2011, 1, 1, 12, 30)
7156 dts = DateTimeSubclass(2011, 1, 1, 12, 30)
7157
7158 is_datetime = _testcapi.datetime_check_datetime
7159
7160 # Check the ones that should be valid
7161 self.assertTrue(is_datetime(dt))
7162 self.assertTrue(is_datetime(dts))
7163 self.assertTrue(is_datetime(dt, True))
7164
7165 # Check that the subclass does not match exactly
7166 self.assertFalse(is_datetime(dts, True))
7167
7168 # Check that various other things are not datetimes
7169 args = [tuple(), list(), 1, '2011-01-01',
7170 timedelta(1), timezone.utc, date(2011, 1, 1)]
7171
7172 for arg in args:
7173 for exact in (True, False):
7174 with self.subTest(arg=arg, exact=exact):
7175 self.assertFalse(is_datetime(arg, exact))
7176
7177 def test_check_delta(self):
7178 class TimeDeltaSubclass(timedelta):

Callers

nothing calls this directly

Calls 8

datetimeClass · 0.90
timedeltaClass · 0.90
dateClass · 0.90
listClass · 0.85
assertTrueMethod · 0.80
assertFalseMethod · 0.80
DateTimeSubclassClass · 0.70
subTestMethod · 0.45

Tested by

no test coverage detected