mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
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.
This commit is contained in:
committed by
Damien George
parent
488613bca6
commit
3dc324d3f1
@@ -1,2 +1,3 @@
|
||||
import sys
|
||||
|
||||
print(sys.argv)
|
||||
|
||||
@@ -5,13 +5,13 @@ import sys
|
||||
try:
|
||||
sys.stdout
|
||||
except AttributeError:
|
||||
print('SKIP')
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
print(file=sys.stdout)
|
||||
print('test', file=sys.stdout)
|
||||
print("test", file=sys.stdout)
|
||||
|
||||
try:
|
||||
print(file=1)
|
||||
except (AttributeError, OSError): # CPython and uPy differ in error message
|
||||
print('Error')
|
||||
except (AttributeError, OSError): # CPython and uPy differ in error message
|
||||
print("Error")
|
||||
|
||||
@@ -4,43 +4,43 @@ print(f.readline())
|
||||
print(f.read())
|
||||
f = open("io/data/file1")
|
||||
print(f.readlines())
|
||||
f = open("io/data/file1","r")
|
||||
f = open("io/data/file1", "r")
|
||||
print(f.readlines())
|
||||
f = open("io/data/file1","rb")
|
||||
f = open("io/data/file1", "rb")
|
||||
print(f.readlines())
|
||||
f = open("io/data/file1",mode="r")
|
||||
f = open("io/data/file1", mode="r")
|
||||
print(f.readlines())
|
||||
f = open("io/data/file1",mode="rb")
|
||||
f = open("io/data/file1", mode="rb")
|
||||
print(f.readlines())
|
||||
|
||||
# write() error
|
||||
f = open('io/data/file1', 'r')
|
||||
f = open("io/data/file1", "r")
|
||||
try:
|
||||
f.write('x')
|
||||
f.write("x")
|
||||
except OSError:
|
||||
print('OSError')
|
||||
print("OSError")
|
||||
f.close()
|
||||
|
||||
# read(n) error on binary file
|
||||
f = open('io/data/file1', 'ab')
|
||||
f = open("io/data/file1", "ab")
|
||||
try:
|
||||
f.read(1)
|
||||
except OSError:
|
||||
print('OSError')
|
||||
print("OSError")
|
||||
f.close()
|
||||
|
||||
# read(n) error on text file
|
||||
f = open('io/data/file1', 'at')
|
||||
f = open("io/data/file1", "at")
|
||||
try:
|
||||
f.read(1)
|
||||
except OSError:
|
||||
print('OSError')
|
||||
print("OSError")
|
||||
f.close()
|
||||
|
||||
# read() w/o args error
|
||||
f = open('io/data/file1', 'ab')
|
||||
f = open("io/data/file1", "ab")
|
||||
try:
|
||||
f.read()
|
||||
except OSError:
|
||||
print('OSError')
|
||||
print("OSError")
|
||||
f.close()
|
||||
|
||||
@@ -7,8 +7,8 @@ print(f.readinto(b))
|
||||
print(b)
|
||||
|
||||
# readinto() on writable file
|
||||
f = open('io/data/file1', 'ab')
|
||||
f = open("io/data/file1", "ab")
|
||||
try:
|
||||
f.readinto(bytearray(4))
|
||||
except OSError:
|
||||
print('OSError')
|
||||
print("OSError")
|
||||
|
||||
@@ -6,9 +6,9 @@ print(f.readline(5))
|
||||
print(f.readline())
|
||||
|
||||
# readline() on writable file
|
||||
f = open('io/data/file1', 'ab')
|
||||
f = open("io/data/file1", "ab")
|
||||
try:
|
||||
f.readline()
|
||||
except OSError:
|
||||
print('OSError')
|
||||
print("OSError")
|
||||
f.close()
|
||||
|
||||
@@ -25,10 +25,10 @@ print(f.tell())
|
||||
f.close()
|
||||
|
||||
# seek closed file
|
||||
f = open('io/data/file1', 'r')
|
||||
f = open("io/data/file1", "r")
|
||||
f.close()
|
||||
try:
|
||||
f.seek(1)
|
||||
except (OSError, ValueError):
|
||||
# CPy raises ValueError, uPy raises OSError
|
||||
print('OSError or ValueError')
|
||||
print("OSError or ValueError")
|
||||
|
||||
@@ -15,7 +15,7 @@ except:
|
||||
# Regression test: test that exception in with initialization properly
|
||||
# thrown and doesn't crash.
|
||||
try:
|
||||
with open('__non_existent', 'r'):
|
||||
with open("__non_existent", "r"):
|
||||
pass
|
||||
except OSError:
|
||||
print("OSError")
|
||||
|
||||
@@ -4,7 +4,7 @@ import sys
|
||||
try:
|
||||
uio.resource_stream
|
||||
except AttributeError:
|
||||
print('SKIP')
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
buf = uio.resource_stream("data", "file2")
|
||||
|
||||
Reference in New Issue
Block a user