Skip to content

Commit 9f20aa1

Browse files
authored
Merge pull request #7 from brentru/fix-failing-tests
Fix failing CI tests on lint
2 parents c2b7164 + 09b35f5 commit 9f20aa1

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

tests/test_date.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# SPDX-FileCopyrightText: 2021 Brent Rubell for Adafruit Industries
99
# SPDX-License-Identifier: Python-2.0
1010
# Implements a subset of https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py
11+
# NOTE: This test is based off CPython and therefore linting is disabled within this file.
12+
# pylint:disable=invalid-name, no-member, wrong-import-position, undefined-variable, no-self-use, cell-var-from-loop, misplaced-comparison-constant, too-many-public-methods, fixme, import-outside-toplevel, unused-argument, too-few-public-methods
1113
import sys
1214
import unittest
1315

tests/test_datetime.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@
88
# SPDX-FileCopyrightText: 2021 Brent Rubell for Adafruit Industries
99
# SPDX-License-Identifier: Python-2.0
1010
# Implements a subset of https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py
11+
# NOTE: This test is based off CPython and therefore linting is disabled within this file.
12+
# 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, too-many-lines, undefined-variable, eval-used, import-outside-toplevel, redefined-outer-name, too-many-locals, reimported, protected-access, wrong-import-position, consider-using-enumerate, wrong-import-order, redefined-builtin, too-many-public-methods
1113
import sys
12-
import unittest
13-
from test import support
14-
from test_date import TestDate
15-
16-
# CPython standard implementation
17-
from datetime import datetime as cpython_datetime
18-
from datetime import MINYEAR, MAXYEAR
1914

2015
# CircuitPython subset implementation
2116
sys.path.append("..")
@@ -26,6 +21,15 @@
2621
from adafruit_datetime import time
2722
from adafruit_datetime import timezone
2823

24+
import unittest
25+
from test import support
26+
from test_date import TestDate
27+
28+
# CPython standard implementation
29+
from datetime import datetime as cpython_datetime
30+
from datetime import MINYEAR, MAXYEAR
31+
32+
2933
# TZinfo test
3034
class FixedOffset(tzinfo):
3135
def __init__(self, offset, name, dstoffset=42):
@@ -268,7 +272,7 @@ def strftime(self, format_spec):
268272
@unittest.skip("ctime not implemented")
269273
def test_more_ctime(self):
270274
# Test fields that TestDate doesn't touch.
271-
import time
275+
import time as cpython_time
272276

273277
t = self.theclass(2002, 3, 2, 18, 3, 5, 123)
274278
self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002")
@@ -280,7 +284,9 @@ def test_more_ctime(self):
280284

281285
# So test a case where that difference doesn't matter.
282286
t = self.theclass(2002, 3, 22, 18, 3, 5, 123)
283-
self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
287+
self.assertEqual(
288+
t.ctime(), cpython_time.ctime(cpython_time.mktime(t.timetuple()))
289+
)
284290

285291
def test_tz_independent_comparing(self):
286292
dt1 = self.theclass(2002, 3, 1, 9, 0, 0)
@@ -537,7 +543,6 @@ def test_timestamp_naive(self):
537543
self.assertEqual(self.theclass.fromtimestamp(t.timestamp()), t)
538544

539545
# Timestamp may raise an overflow error on some platforms
540-
# XXX: Do we care to support the first and last year?
541546
for t in [self.theclass(2, 1, 1), self.theclass(9998, 12, 12)]:
542547
try:
543548
s = t.timestamp()

tests/test_time.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
# SPDX-FileCopyrightText: 2021 Brent Rubell for Adafruit Industries
99
# SPDX-License-Identifier: Python-2.0
1010
# Implements a subset of https://github.com/python/cpython/blob/master/Lib/test/datetimetester.py
11-
import unittest
12-
13-
# CPython standard implementation
14-
from datetime import time as cpython_time
15-
11+
# NOTE: This test is based off CPython and therefore linting is disabled within this file.
12+
# pylint:disable=invalid-name, no-member, cell-var-from-loop, unused-argument, no-self-use, too-few-public-methods, consider-using-enumerate, undefined-variable, wrong-import-order, wrong-import-position
1613
# CircuitPython subset implementation
1714
import sys
1815

1916
sys.path.append("..")
2017
from adafruit_datetime import time as cpy_time
2118

19+
# CPython standard implementation
20+
from datetime import time as cpython_time
21+
import unittest
22+
23+
2224
# An arbitrary collection of objects of non-datetime types, for testing
2325
# mixed-type comparisons.
2426
OTHERSTUFF = (10, 34.5, "abc", {}, [], ())

0 commit comments

Comments
 (0)