Skip to content

Commit 9d989e4

Browse files
dhalbertdpgeorge
authored andcommitted
tests: Remove further trailing spaces when possible.
Most cases here have `print(..., some_str)` changed to `print(..., repr(some_str))`. This makes the empty string visible and prevents bare trailing spaces. Signed-off-by: Dan Halbert <halbert@halwitz.org>
1 parent 93a7340 commit 9d989e4

12 files changed

Lines changed: 51 additions & 50 deletions

tests/basics/string_tstring_basic.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@
172172
print("\n=== Interpolation attribute tests ===")
173173
i_basic = Interpolation(42, "x")
174174
print(f"Basic conversion: {i_basic.conversion}")
175-
print(f"Basic format_spec: {i_basic.format_spec}")
175+
# Put in quotes to make empty string visible.
176+
print(f"Basic format_spec: '{i_basic.format_spec}'")
176177

177178
i_with_conv = Interpolation(42, "x", "s")
178179
print(f"With conversion: {i_with_conv.conversion}")

tests/basics/string_tstring_basic.py.exp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Nested expr: Template(strings=('', ''), interpolations=(Interpolation('{}', 'inn
7171

7272
=== Interpolation attribute tests ===
7373
Basic conversion: None
74-
Basic format_spec:
74+
Basic format_spec: ''
7575
With conversion: s
7676
With format_spec: :>10
7777
Full conversion: r

tests/cmdline/repl_paste.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def calculate(n):
2626
{\x05}
2727
def function_with_blanks():
2828
print('First line')
29-
29+
{\x20}{\x20}{\x20}{\x20}
3030
print('After blank line')
31-
32-
31+
{\x20}{\x20}{\x20}{\x20}
32+
{\x20}{\x20}{\x20}{\x20}
3333
print('After two blank lines')
3434

3535
function_with_blanks()
@@ -40,10 +40,10 @@ def function_with_blanks():
4040
class TestClass:
4141
def __init__(self, value):
4242
self.value = value
43-
43+
{\x20}{\x20}{\x20}{\x20}
4444
def display(self):
4545
print(f'Value is: {self.value}')
46-
46+
{\x20}{\x20}{\x20}{\x20}
4747
def double(self):
4848
self.value *= 2
4949
return self.value
@@ -82,7 +82,7 @@ def bad_syntax(:
8282
{\x05}
8383
def will_error():
8484
undefined_variable
85-
85+
{\x20}{\x20}{\x20}{\x20}
8686
will_error()
8787
{\x04}
8888

tests/extmod/vfs_basic.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ def umount(self):
1919
print(self.id, "umount")
2020

2121
def ilistdir(self, dir):
22-
print(self.id, "ilistdir", dir)
22+
print(self.id, "ilistdir", repr(dir))
2323
return iter([("a%d" % self.id, 0, 0)])
2424

2525
def chdir(self, dir):
26-
print(self.id, "chdir", dir)
26+
print(self.id, "chdir", repr(dir))
2727
if self.fail:
2828
raise OSError(self.fail)
2929

@@ -32,23 +32,23 @@ def getcwd(self):
3232
return "dir%d" % self.id
3333

3434
def mkdir(self, path):
35-
print(self.id, "mkdir", path)
35+
print(self.id, "mkdir", repr(path))
3636

3737
def remove(self, path):
38-
print(self.id, "remove", path)
38+
print(self.id, "remove", repr(path))
3939

4040
def rename(self, old_path, new_path):
41-
print(self.id, "rename", old_path, new_path)
41+
print(self.id, "rename", repr(old_path), repr(new_path))
4242

4343
def rmdir(self, path):
44-
print(self.id, "rmdir", path)
44+
print(self.id, "rmdir", repr(path))
4545

4646
def stat(self, path):
47-
print(self.id, "stat", path)
47+
print(self.id, "stat", repr(path))
4848
return (self.id,)
4949

5050
def statvfs(self, path):
51-
print(self.id, "statvfs", path)
51+
print(self.id, "statvfs", repr(path))
5252
return (self.id,)
5353

5454
def open(self, file, mode):

tests/extmod/vfs_basic.py.exp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,30 @@ stat /x OSError
1818
('test_mnt', 16384, 0)
1919
StopIteration
2020
StopIteration
21-
1 ilistdir /
21+
1 ilistdir '/'
2222
['a1']
23-
1 ilistdir /
23+
1 ilistdir '/'
2424
['a1']
2525
2 mount True False
2626
['test_mnt', 'test_mnt2']
27-
2 ilistdir /
27+
2 ilistdir '/'
2828
['a2']
2929
3 mount False False
3030
OSError
3131
OSError
3232
OSError
33-
1 chdir /
34-
1 ilistdir
33+
1 chdir '/'
34+
1 ilistdir ''
3535
['a1']
3636
1 getcwd
3737
/test_mntdir1
38-
1 mkdir test_dir
39-
1 remove test_file
40-
1 rename test_file test_file2
41-
1 rmdir test_dir
42-
1 stat test_file
38+
1 mkdir 'test_dir'
39+
1 remove 'test_file'
40+
1 rename 'test_file' 'test_file2'
41+
1 rmdir 'test_dir'
42+
1 stat 'test_file'
4343
(1,)
44-
1 statvfs /
44+
1 statvfs '/'
4545
(1,)
4646
1 open test_file r
4747
1 open test_file wb
@@ -50,29 +50,29 @@ OSError
5050
OSError
5151
3 mount False False
5252
(16384, 0, 0, 0, 0, 0, 0, 0, 0, 0)
53-
3 statvfs /
53+
3 statvfs '/'
5454
(3,)
55-
3 ilistdir /
55+
3 ilistdir '/'
5656
['a3']
5757
3 open test r
5858
4 mount False False
59-
3 ilistdir /
59+
3 ilistdir '/'
6060
['mnt', 'a3']
61-
4 ilistdir /
61+
4 ilistdir '/'
6262
['a4']
63-
4 chdir /
64-
4 ilistdir
63+
4 chdir '/'
64+
4 ilistdir ''
6565
['a4']
66-
3 chdir /subdir
67-
3 ilistdir
66+
3 chdir '/subdir'
67+
3 ilistdir ''
6868
['a3']
69-
3 chdir /
69+
3 chdir '/'
7070
3 umount
7171
['mnt']
7272
4 umount
7373
OSError
7474
/
7575
5 mount False False
76-
5 chdir /subdir
76+
5 chdir '/subdir'
7777
OSError
7878
/

tests/micropython/heapalloc_traceback.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def test():
3030
# call test() with heap allocation disabled
3131
test()
3232

33-
# print the exception that was raised
33+
# print the exception that was raised. Use repr() to make the whitespace visible.
3434
buf = io.StringIO()
3535
sys.print_exception(global_exc, buf)
3636
for l in buf.getvalue().split("\n"):
3737
# MicroPython on pyboard prints <stdin> as file, so remove filename.
3838
if l.startswith(" File "):
3939
l = l.split('"')
40-
print(l[0], l[2])
40+
print(repr(l[0]), repr(l[2]))
4141
else:
42-
print(l)
42+
print(repr(l))
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
StopIteration
2-
Traceback (most recent call last):
3-
File , line 24, in test
4-
StopIteration:
5-
2+
'Traceback (most recent call last):'
3+
' File ' ', line 24, in test'
4+
'StopIteration: '
5+
''
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
StopIteration
2-
StopIteration:
3-
2+
'StopIteration: '
3+
''

tests/ports/esp32/check_err_str.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
except OSError as e:
3333
exc = e
3434
micropython.heap_unlock()
35-
print("exc:", exc) # exc empty due to no memory
35+
print("exc:", repr(exc)) # exc empty due to no memory
3636

3737
# same again but having an emergency buffer
3838
micropython.alloc_emergency_exception_buf(256)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[Errno 2] ENOENT
22
(-5379, 'ESP_ERR_OTA_VALIDATE_FAILED')
3-
exc:
3+
exc: OSError()
44
-5379

0 commit comments

Comments
 (0)