kopia lustrzana https://github.com/micropython/micropython
tests/basics: Use str.format instead of % for formatting messages.
Only use % formatting when testing % itself, because only str.format is guaranteed to be available on any port.pull/5227/head
rodzic
4847460232
commit
709136e844
|
@ -11,7 +11,7 @@ else:
|
||||||
@coroutine
|
@coroutine
|
||||||
def wait(value):
|
def wait(value):
|
||||||
print('wait value:', value)
|
print('wait value:', value)
|
||||||
msg = yield 'message from wait(%u)' % value
|
msg = yield 'message from wait({})'.format(value)
|
||||||
print('wait got back:', msg)
|
print('wait got back:', msg)
|
||||||
return 10
|
return 10
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class A:
|
||||||
return A(self.v + o.v)
|
return A(self.v + o.v)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "A(%s)" % self.v
|
return "A({})".format(self.v)
|
||||||
|
|
||||||
a = A(5)
|
a = A(5)
|
||||||
b = a
|
b = a
|
||||||
|
@ -37,7 +37,7 @@ class L:
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "L(%s)" % self.v
|
return "L({})".format(self.v)
|
||||||
|
|
||||||
c = L([1, 2])
|
c = L([1, 2])
|
||||||
d = c
|
d = c
|
||||||
|
|
|
@ -11,7 +11,7 @@ class C:
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "C(%s)" % self.value
|
return "C({})".format(self.value)
|
||||||
|
|
||||||
def __add__(self, rhs):
|
def __add__(self, rhs):
|
||||||
print(self, '+', rhs)
|
print(self, '+', rhs)
|
||||||
|
|
|
@ -12,7 +12,7 @@ class A:
|
||||||
return A(self.v + o)
|
return A(self.v + o)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "A(%s)" % self.v
|
return "A({})".format(self.v)
|
||||||
|
|
||||||
print(A(3) + 1)
|
print(A(3) + 1)
|
||||||
print(2 + A(5))
|
print(2 + A(5))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# anything above 0xa0 is printed as Unicode by CPython
|
# anything above 0xa0 is printed as Unicode by CPython
|
||||||
# the abobe is CPython implementation detail, stick to ASCII
|
# the abobe is CPython implementation detail, stick to ASCII
|
||||||
for c in range(0x80):
|
for c in range(0x80):
|
||||||
print("0x%02x: %s" % (c, repr(chr(c))))
|
print("0x{:02x}: {}".format(c, repr(chr(c))))
|
||||||
|
|
Ładowanie…
Reference in New Issue