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

Method test_check_datetime

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

Source from the content-addressed store, hash-verified

6962 self.assertFalse(is_time(arg, exact))
6963
6964 def test_check_datetime(self):
6965 class DateTimeSubclass(datetime):
6966 pass
6967
6968 dt = datetime(2011, 1, 1, 12, 30)
6969 dts = DateTimeSubclass(2011, 1, 1, 12, 30)
6970
6971 is_datetime = _testcapi.datetime_check_datetime
6972
6973 # Check the ones that should be valid
6974 self.assertTrue(is_datetime(dt))
6975 self.assertTrue(is_datetime(dts))
6976 self.assertTrue(is_datetime(dt, True))
6977
6978 # Check that the subclass does not match exactly
6979 self.assertFalse(is_datetime(dts, True))
6980
6981 # Check that various other things are not datetimes
6982 args = [tuple(), list(), 1, '2011-01-01',
6983 timedelta(1), timezone.utc, date(2011, 1, 1)]
6984
6985 for arg in args:
6986 for exact in (True, False):
6987 with self.subTest(arg=arg, exact=exact):
6988 self.assertFalse(is_datetime(arg, exact))
6989
6990 def test_check_delta(self):
6991 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
subTestMethod · 0.80
DateTimeSubclassClass · 0.70

Tested by

no test coverage detected