mirror of
https://github.com/micropython/micropython.git
synced 2026-05-01 05:10:15 +02:00
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>
This commit is contained in:
committed by
Damien George
parent
93a734020e
commit
9d989e4d8b
@@ -172,7 +172,8 @@ print(f" Value: {t_nested_expr.interpolations[0].value}")
|
||||
print("\n=== Interpolation attribute tests ===")
|
||||
i_basic = Interpolation(42, "x")
|
||||
print(f"Basic conversion: {i_basic.conversion}")
|
||||
print(f"Basic format_spec: {i_basic.format_spec}")
|
||||
# Put in quotes to make empty string visible.
|
||||
print(f"Basic format_spec: '{i_basic.format_spec}'")
|
||||
|
||||
i_with_conv = Interpolation(42, "x", "s")
|
||||
print(f"With conversion: {i_with_conv.conversion}")
|
||||
|
||||
@@ -71,7 +71,7 @@ Nested expr: Template(strings=('', ''), interpolations=(Interpolation('{}', 'inn
|
||||
|
||||
=== Interpolation attribute tests ===
|
||||
Basic conversion: None
|
||||
Basic format_spec:
|
||||
Basic format_spec: ''
|
||||
With conversion: s
|
||||
With format_spec: :>10
|
||||
Full conversion: r
|
||||
|
||||
@@ -26,10 +26,10 @@ calculate(5)
|
||||
{\x05}
|
||||
def function_with_blanks():
|
||||
print('First line')
|
||||
|
||||
{\x20}{\x20}{\x20}{\x20}
|
||||
print('After blank line')
|
||||
|
||||
|
||||
{\x20}{\x20}{\x20}{\x20}
|
||||
{\x20}{\x20}{\x20}{\x20}
|
||||
print('After two blank lines')
|
||||
|
||||
function_with_blanks()
|
||||
@@ -40,10 +40,10 @@ function_with_blanks()
|
||||
class TestClass:
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
{\x20}{\x20}{\x20}{\x20}
|
||||
def display(self):
|
||||
print(f'Value is: {self.value}')
|
||||
|
||||
{\x20}{\x20}{\x20}{\x20}
|
||||
def double(self):
|
||||
self.value *= 2
|
||||
return self.value
|
||||
@@ -82,7 +82,7 @@ def bad_syntax(:
|
||||
{\x05}
|
||||
def will_error():
|
||||
undefined_variable
|
||||
|
||||
{\x20}{\x20}{\x20}{\x20}
|
||||
will_error()
|
||||
{\x04}
|
||||
|
||||
|
||||
@@ -19,11 +19,11 @@ class Filesystem:
|
||||
print(self.id, "umount")
|
||||
|
||||
def ilistdir(self, dir):
|
||||
print(self.id, "ilistdir", dir)
|
||||
print(self.id, "ilistdir", repr(dir))
|
||||
return iter([("a%d" % self.id, 0, 0)])
|
||||
|
||||
def chdir(self, dir):
|
||||
print(self.id, "chdir", dir)
|
||||
print(self.id, "chdir", repr(dir))
|
||||
if self.fail:
|
||||
raise OSError(self.fail)
|
||||
|
||||
@@ -32,23 +32,23 @@ class Filesystem:
|
||||
return "dir%d" % self.id
|
||||
|
||||
def mkdir(self, path):
|
||||
print(self.id, "mkdir", path)
|
||||
print(self.id, "mkdir", repr(path))
|
||||
|
||||
def remove(self, path):
|
||||
print(self.id, "remove", path)
|
||||
print(self.id, "remove", repr(path))
|
||||
|
||||
def rename(self, old_path, new_path):
|
||||
print(self.id, "rename", old_path, new_path)
|
||||
print(self.id, "rename", repr(old_path), repr(new_path))
|
||||
|
||||
def rmdir(self, path):
|
||||
print(self.id, "rmdir", path)
|
||||
print(self.id, "rmdir", repr(path))
|
||||
|
||||
def stat(self, path):
|
||||
print(self.id, "stat", path)
|
||||
print(self.id, "stat", repr(path))
|
||||
return (self.id,)
|
||||
|
||||
def statvfs(self, path):
|
||||
print(self.id, "statvfs", path)
|
||||
print(self.id, "statvfs", repr(path))
|
||||
return (self.id,)
|
||||
|
||||
def open(self, file, mode):
|
||||
|
||||
@@ -18,30 +18,30 @@ stat /x OSError
|
||||
('test_mnt', 16384, 0)
|
||||
StopIteration
|
||||
StopIteration
|
||||
1 ilistdir /
|
||||
1 ilistdir '/'
|
||||
['a1']
|
||||
1 ilistdir /
|
||||
1 ilistdir '/'
|
||||
['a1']
|
||||
2 mount True False
|
||||
['test_mnt', 'test_mnt2']
|
||||
2 ilistdir /
|
||||
2 ilistdir '/'
|
||||
['a2']
|
||||
3 mount False False
|
||||
OSError
|
||||
OSError
|
||||
OSError
|
||||
1 chdir /
|
||||
1 ilistdir
|
||||
1 chdir '/'
|
||||
1 ilistdir ''
|
||||
['a1']
|
||||
1 getcwd
|
||||
/test_mntdir1
|
||||
1 mkdir test_dir
|
||||
1 remove test_file
|
||||
1 rename test_file test_file2
|
||||
1 rmdir test_dir
|
||||
1 stat test_file
|
||||
1 mkdir 'test_dir'
|
||||
1 remove 'test_file'
|
||||
1 rename 'test_file' 'test_file2'
|
||||
1 rmdir 'test_dir'
|
||||
1 stat 'test_file'
|
||||
(1,)
|
||||
1 statvfs /
|
||||
1 statvfs '/'
|
||||
(1,)
|
||||
1 open test_file r
|
||||
1 open test_file wb
|
||||
@@ -50,29 +50,29 @@ OSError
|
||||
OSError
|
||||
3 mount False False
|
||||
(16384, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
3 statvfs /
|
||||
3 statvfs '/'
|
||||
(3,)
|
||||
3 ilistdir /
|
||||
3 ilistdir '/'
|
||||
['a3']
|
||||
3 open test r
|
||||
4 mount False False
|
||||
3 ilistdir /
|
||||
3 ilistdir '/'
|
||||
['mnt', 'a3']
|
||||
4 ilistdir /
|
||||
4 ilistdir '/'
|
||||
['a4']
|
||||
4 chdir /
|
||||
4 ilistdir
|
||||
4 chdir '/'
|
||||
4 ilistdir ''
|
||||
['a4']
|
||||
3 chdir /subdir
|
||||
3 ilistdir
|
||||
3 chdir '/subdir'
|
||||
3 ilistdir ''
|
||||
['a3']
|
||||
3 chdir /
|
||||
3 chdir '/'
|
||||
3 umount
|
||||
['mnt']
|
||||
4 umount
|
||||
OSError
|
||||
/
|
||||
5 mount False False
|
||||
5 chdir /subdir
|
||||
5 chdir '/subdir'
|
||||
OSError
|
||||
/
|
||||
|
||||
@@ -30,13 +30,13 @@ def test():
|
||||
# call test() with heap allocation disabled
|
||||
test()
|
||||
|
||||
# print the exception that was raised
|
||||
# print the exception that was raised. Use repr() to make the whitespace visible.
|
||||
buf = io.StringIO()
|
||||
sys.print_exception(global_exc, buf)
|
||||
for l in buf.getvalue().split("\n"):
|
||||
# MicroPython on pyboard prints <stdin> as file, so remove filename.
|
||||
if l.startswith(" File "):
|
||||
l = l.split('"')
|
||||
print(l[0], l[2])
|
||||
print(repr(l[0]), repr(l[2]))
|
||||
else:
|
||||
print(l)
|
||||
print(repr(l))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
StopIteration
|
||||
Traceback (most recent call last):
|
||||
File , line 24, in test
|
||||
StopIteration:
|
||||
|
||||
'Traceback (most recent call last):'
|
||||
' File ' ', line 24, in test'
|
||||
'StopIteration: '
|
||||
''
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
StopIteration
|
||||
StopIteration:
|
||||
|
||||
'StopIteration: '
|
||||
''
|
||||
|
||||
@@ -32,7 +32,7 @@ try:
|
||||
except OSError as e:
|
||||
exc = e
|
||||
micropython.heap_unlock()
|
||||
print("exc:", exc) # exc empty due to no memory
|
||||
print("exc:", repr(exc)) # exc empty due to no memory
|
||||
|
||||
# same again but having an emergency buffer
|
||||
micropython.alloc_emergency_exception_buf(256)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[Errno 2] ENOENT
|
||||
(-5379, 'ESP_ERR_OTA_VALIDATE_FAILED')
|
||||
exc:
|
||||
exc: OSError()
|
||||
-5379
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Unhandled exception in thread started by <function thread_entry at 0x\[0-9a-f\]\+>
|
||||
Traceback (most recent call last):
|
||||
File \.\+, line 7, in thread_entry
|
||||
ValueError:
|
||||
ValueError: \$
|
||||
done
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
Unhandled exception in thread started by <function thread_entry at 0x\[0-9a-f\]\+>
|
||||
ValueError:
|
||||
ValueError: \$
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user