From 6c51b42e33e0dfaffe16539c79eaf7e8cad42607 Mon Sep 17 00:00:00 2001 From: brentru Date: Wed, 17 Mar 2021 11:43:21 -0400 Subject: [PATCH] pass time --- tests/test_datetime.py | 24 +++++++++++++----------- tests/test_time.py | 10 +++++----- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/test_datetime.py b/tests/test_datetime.py index 140bd84..f3ac3c0 100644 --- a/tests/test_datetime.py +++ b/tests/test_datetime.py @@ -8,15 +8,9 @@ # SPDX-FileCopyrightText: 2021 Brent Rubell for Adafruit Industries # SPDX-License-Identifier: Python-2.0 # Implements a subset of https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py +# NOTE: This test is based off CPython and therefore linting is disabled within this file. +# pylint:disable = invalid-name, no-member, cell-var-from-loop, unused-argument, no-self-use, too-few-public-methods, raise-missing-from, too-many-statements import sys -import unittest -from test import support -from test_date import TestDate - -# CPython standard implementation -from datetime import datetime as cpython_datetime -from datetime import MINYEAR, MAXYEAR - # CircuitPython subset implementation sys.path.append("..") from adafruit_datetime import datetime as cpy_datetime @@ -26,6 +20,15 @@ from adafruit_datetime import date from adafruit_datetime import time from adafruit_datetime import timezone +import unittest +from test import support +from test_date import TestDate + +# CPython standard implementation +from datetime import datetime as cpython_datetime +from datetime import MINYEAR, MAXYEAR + + # TZinfo test class FixedOffset(tzinfo): def __init__(self, offset, name, dstoffset=42): @@ -268,7 +271,7 @@ class TestDateTime(TestDate): @unittest.skip("ctime not implemented") def test_more_ctime(self): # Test fields that TestDate doesn't touch. - import time + import time as cpython_time t = self.theclass(2002, 3, 2, 18, 3, 5, 123) self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002") @@ -280,7 +283,7 @@ class TestDateTime(TestDate): # So test a case where that difference doesn't matter. t = self.theclass(2002, 3, 22, 18, 3, 5, 123) - self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple()))) + self.assertEqual(t.ctime(), cpython_time.ctime(cpython_time.mktime(t.timetuple()))) def test_tz_independent_comparing(self): dt1 = self.theclass(2002, 3, 1, 9, 0, 0) @@ -537,7 +540,6 @@ class TestDateTime(TestDate): self.assertEqual(self.theclass.fromtimestamp(t.timestamp()), t) # Timestamp may raise an overflow error on some platforms - # XXX: Do we care to support the first and last year? for t in [self.theclass(2, 1, 1), self.theclass(9998, 12, 12)]: try: s = t.timestamp() diff --git a/tests/test_time.py b/tests/test_time.py index b1e39ad..04f9bc8 100644 --- a/tests/test_time.py +++ b/tests/test_time.py @@ -9,15 +9,15 @@ # SPDX-License-Identifier: Python-2.0 # Implements a subset of https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py # NOTE: This test is based off CPython and therefore linting is disabled within this file. -# pylint:disable = invalid-name, no-member, cell-var-from-loop, unused-argument, no-self-use, too-few-public-methods, +# pylint:disable = invalid-name, no-member, cell-var-from-loop, unused-argument, no-self-use, too-few-public-methods, consider-using-enumerate, undefined-variable +# CircuitPython subset implementation +import sys +sys.path.append("..") +from adafruit_datetime import time as cpy_time # CPython standard implementation from datetime import time as cpython_time import unittest -# CircuitPython subset implementation -import sys -sys.path.append("..") -from adafruit_datetime import time as cpy_time # An arbitrary collection of objects of non-datetime types, for testing # mixed-type comparisons.