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
Damien George 2019-10-18 19:18:06 +11:00
rodzic 4847460232
commit 709136e844
5 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -11,7 +11,7 @@ else:
@coroutine
def wait(value):
print('wait value:', value)
msg = yield 'message from wait(%u)' % value
msg = yield 'message from wait({})'.format(value)
print('wait got back:', msg)
return 10

Wyświetl plik

@ -10,7 +10,7 @@ class A:
return A(self.v + o.v)
def __repr__(self):
return "A(%s)" % self.v
return "A({})".format(self.v)
a = A(5)
b = a
@ -37,7 +37,7 @@ class L:
return self
def __repr__(self):
return "L(%s)" % self.v
return "L({})".format(self.v)
c = L([1, 2])
d = c

Wyświetl plik

@ -11,7 +11,7 @@ class C:
self.value = value
def __str__(self):
return "C(%s)" % self.value
return "C({})".format(self.value)
def __add__(self, rhs):
print(self, '+', rhs)

Wyświetl plik

@ -12,7 +12,7 @@ class A:
return A(self.v + o)
def __repr__(self):
return "A(%s)" % self.v
return "A({})".format(self.v)
print(A(3) + 1)
print(2 + A(5))

Wyświetl plik

@ -1,4 +1,4 @@
# anything above 0xa0 is printed as Unicode by CPython
# the abobe is CPython implementation detail, stick to ASCII
for c in range(0x80):
print("0x%02x: %s" % (c, repr(chr(c))))
print("0x{:02x}: {}".format(c, repr(chr(c))))