summaryrefslogtreecommitdiff
path: root/tests/unix/time.py
diff options
context:
space:
mode:
authorDavid Lechner <david@lechnology.com>2020-03-22 21:26:08 -0500
committerDamien George <damien.p.george@gmail.com>2020-03-30 13:21:58 +1100
commit3dc324d3f1312e40d3a8ed87e7244966bb756f26 (patch)
tree94ff44f8eabba0039582c245b901173597edd11e /tests/unix/time.py
parent488613bca6c460340ed2995ae5cafafe22d0bfff (diff)
tests: Format all Python code with black, except tests in basics subdir.
This adds the Python files in the tests/ directory to be formatted with ./tools/codeformat.py. The basics/ subdirectory is excluded for now so we aren't changing too much at once. In a few places `# fmt: off`/`# fmt: on` was used where the code had special formatting for readability or where the test was actually testing the specific formatting.
Diffstat (limited to 'tests/unix/time.py')
-rw-r--r--tests/unix/time.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/tests/unix/time.py b/tests/unix/time.py
index 35eddbe09..55a4b18aa 100644
--- a/tests/unix/time.py
+++ b/tests/unix/time.py
@@ -7,12 +7,14 @@ DAYS_PER_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
tzseconds = -time.mktime((1970, 1, 1, 14, 0, 0, 0, 0, 0))
+
def is_leap(year):
return (year % 4) == 0
+
def test():
seconds = 0
- wday = 3 # Jan 1, 1970 was a Thursday
+ wday = 3 # Jan 1, 1970 was a Thursday
for year in range(1970, 2038):
print("Testing %d" % year)
yday = 1
@@ -24,21 +26,34 @@ def test():
for day in range(1, DAYS_PER_MONTH[month] + 1):
secs = time.mktime((year, month, day, 14, 0, 0, 0, 0, 0)) + tzseconds
if secs != seconds:
- print("mktime failed for %d-%02d-%02d got %d expected %d" % (year, month, day, secs, seconds))
+ print(
+ "mktime failed for %d-%02d-%02d got %d expected %d"
+ % (year, month, day, secs, seconds)
+ )
return
tuple = time.localtime(seconds)
secs = time.mktime(tuple)
if secs != seconds:
- print("localtime failed for %d-%02d-%02d got %d expected %d" % (year, month, day, secs, seconds))
+ print(
+ "localtime failed for %d-%02d-%02d got %d expected %d"
+ % (year, month, day, secs, seconds)
+ )
return
seconds += 86400
if yday != tuple[7]:
- print("locatime for %d-%02d-%02d got yday %d, expecting %d" % (year, month, day, tuple[7], yday))
+ print(
+ "locatime for %d-%02d-%02d got yday %d, expecting %d"
+ % (year, month, day, tuple[7], yday)
+ )
return
if wday != tuple[6]:
- print("locatime for %d-%02d-%02d got wday %d, expecting %d" % (year, month, day, tuple[6], wday))
+ print(
+ "locatime for %d-%02d-%02d got wday %d, expecting %d"
+ % (year, month, day, tuple[6], wday)
+ )
return
yday += 1
wday = (wday + 1) % 7
+
test()