Skip to content

Commit 3dc324d

Browse files
dlechdpgeorge
authored andcommitted
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.
1 parent 488613b commit 3dc324d

File tree

472 files changed

+4352
-2847
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

472 files changed

+4352
-2847
lines changed

tests/cmdline/cmd_parsetree.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
for i in ():
55
pass
66
a = None
7-
b = 'str'
8-
c = 'a very long str that will not be interned'
9-
d = b'bytes'
10-
e = b'a very long bytes that will not be interned'
7+
b = "str"
8+
c = "a very long str that will not be interned"
9+
d = b"bytes"
10+
e = b"a very long bytes that will not be interned"
1111
f = 123456789012345678901234567890
1212
g = 123

tests/cmdline/cmd_showbc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# cmdline: -v -v
22
# test printing of all bytecodes
3+
# fmt: off
34

45
def f():
56
# constants

tests/cmdline/cmd_showbc.py.exp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ arg names:
77
(N_EXC_STACK 0)
88
bc=0 line=1
99
########
10-
bc=\\d\+ line=159
10+
bc=\\d\+ line=160
1111
00 MAKE_FUNCTION \.\+
1212
\\d\+ STORE_NAME f
1313
\\d\+ MAKE_FUNCTION \.\+
@@ -45,7 +45,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
4545
(INIT_CELL 16)
4646
bc=0 line=1
4747
########
48-
bc=\\d\+ line=126
48+
bc=\\d\+ line=127
4949
00 LOAD_CONST_NONE
5050
01 LOAD_CONST_FALSE
5151
02 BINARY_OP 27 __add__
@@ -320,7 +320,7 @@ Raw bytecode (code_info_size=\\d\+, bytecode_size=\\d\+):
320320
(N_EXC_STACK 0)
321321
bc=0 line=1
322322
########
323-
bc=\\d\+ line=132
323+
bc=\\d\+ line=133
324324
00 LOAD_CONST_SMALL_INT 1
325325
01 DUP_TOP
326326
02 STORE_FAST 0
@@ -376,7 +376,7 @@ arg names: a
376376
(N_EXC_STACK 0)
377377
(INIT_CELL 0)
378378
########
379-
bc=\\d\+ line=138
379+
bc=\\d\+ line=139
380380
00 LOAD_CONST_SMALL_INT 2
381381
01 BUILD_TUPLE 1
382382
03 LOAD_NULL
@@ -393,9 +393,9 @@ arg names:
393393
(N_STATE 2)
394394
(N_EXC_STACK 0)
395395
bc=0 line=1
396-
bc=0 line=143
397-
bc=3 line=144
398-
bc=6 line=145
396+
bc=0 line=144
397+
bc=3 line=145
398+
bc=6 line=146
399399
00 LOAD_CONST_NONE
400400
01 YIELD_VALUE
401401
02 POP_TOP
@@ -418,7 +418,7 @@ arg names:
418418
(N_EXC_STACK 0)
419419
bc=0 line=1
420420
########
421-
bc=13 line=149
421+
bc=13 line=150
422422
00 LOAD_NAME __name__ (cache=0)
423423
04 STORE_NAME __module__
424424
07 LOAD_CONST_STRING 'Class'
@@ -433,7 +433,7 @@ arg names: self
433433
(N_STATE 4)
434434
(N_EXC_STACK 0)
435435
bc=0 line=1
436-
bc=0 line=156
436+
bc=0 line=157
437437
00 LOAD_GLOBAL super (cache=0)
438438
\\d\+ LOAD_GLOBAL __class__ (cache=0)
439439
\\d\+ LOAD_FAST 0
@@ -450,7 +450,7 @@ arg names: * * *
450450
(N_STATE 9)
451451
(N_EXC_STACK 0)
452452
bc=0 line=1
453-
bc=0 line=59
453+
bc=0 line=60
454454
########
455455
00 LOAD_NULL
456456
01 LOAD_FAST 2
@@ -474,7 +474,7 @@ arg names: * * *
474474
(N_STATE 10)
475475
(N_EXC_STACK 0)
476476
bc=0 line=1
477-
bc=0 line=60
477+
bc=0 line=61
478478
########
479479
00 BUILD_LIST 0
480480
02 LOAD_FAST 2
@@ -517,7 +517,7 @@ arg names: *
517517
(N_EXC_STACK 0)
518518
bc=0 line=1
519519
########
520-
bc=\\d\+ line=113
520+
bc=\\d\+ line=114
521521
00 LOAD_DEREF 0
522522
02 LOAD_CONST_SMALL_INT 1
523523
03 BINARY_OP 27 __add__
@@ -536,7 +536,7 @@ arg names: * b
536536
(N_EXC_STACK 0)
537537
bc=0 line=1
538538
########
539-
bc=\\d\+ line=139
539+
bc=\\d\+ line=140
540540
00 LOAD_FAST 1
541541
01 LOAD_DEREF 0
542542
03 BINARY_OP 27 __add__

tests/cpydiff/core_class_delnotimpl.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"""
77
import gc
88

9-
class Foo():
9+
10+
class Foo:
1011
def __del__(self):
11-
print('__del__')
12+
print("__del__")
13+
1214

1315
f = Foo()
1416
del f

tests/cpydiff/core_class_mro.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
cause: Depth first non-exhaustive method resolution order
55
workaround: Avoid complex class hierarchies with multiple inheritance and complex method overrides. Keep in mind that many languages don't support multiple inheritance at all.
66
"""
7+
8+
79
class Foo:
810
def __str__(self):
911
return "Foo"
1012

13+
1114
class C(tuple, Foo):
1215
pass
1316

17+
1418
t = C((1, 2, 3))
1519
print(t)

tests/cpydiff/core_class_supermultiple.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@
44
cause: See :ref:`cpydiff_core_class_mro`
55
workaround: See :ref:`cpydiff_core_class_mro`
66
"""
7+
8+
79
class A:
810
def __init__(self):
911
print("A.__init__")
1012

13+
1114
class B(A):
1215
def __init__(self):
1316
print("B.__init__")
1417
super().__init__()
1518

19+
1620
class C(A):
1721
def __init__(self):
1822
print("C.__init__")
1923
super().__init__()
2024

2125

22-
class D(B,C):
26+
class D(B, C):
2327
def __init__(self):
2428
print("D.__init__")
2529
super().__init__()
2630

31+
2732
D()

tests/cpydiff/core_class_superproperty.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
cause: Unknown
55
workaround: Unknown
66
"""
7+
8+
79
class A:
810
@property
911
def p(self):
10-
return {"a":10}
12+
return {"a": 10}
13+
1114

1215
class AA(A):
1316
@property
1417
def p(self):
1518
return super().p
1619

20+
1721
a = AA()
1822
print(a.p)

tests/cpydiff/core_function_userattr.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
cause: MicroPython is highly optimized for memory usage.
55
workaround: Use external dictionary, e.g. ``FUNC_X[f] = 0``.
66
"""
7+
8+
79
def f():
810
pass
911

12+
1013
f.x = 0
1114
print(f.x)

tests/cpydiff/core_generator_noexit.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@
44
cause: Unknown
55
workaround: Unknown
66
"""
7+
8+
79
class foo(object):
810
def __enter__(self):
9-
print('Enter')
11+
print("Enter")
12+
1013
def __exit__(self, *args):
11-
print('Exit')
14+
print("Exit")
15+
1216

1317
def bar(x):
1418
with foo():
1519
while True:
1620
x += 1
1721
yield x
1822

23+
1924
def func():
2025
g = bar(0)
2126
for _ in range(3):
2227
print(next(g))
2328

29+
2430
func()

tests/cpydiff/core_import_prereg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
print(e)
1313
try:
1414
from modules import foo
15-
print('Should not get here')
15+
16+
print("Should not get here")
1617
except NameError as e:
1718
print(e)

0 commit comments

Comments
 (0)