summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-10-18 19:18:06 +1100
committerDamien George <damien.p.george@gmail.com>2019-10-29 22:22:37 +1100
commit709136e844f93eb7b9ea8c14e9daa5da8e8293d3 (patch)
treed2b585ef47209d414dccbe4ab5383979370baf7d
parent4847460232764a116b731da077074818e316fb55 (diff)
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.
-rw-r--r--tests/basics/async_await2.py2
-rw-r--r--tests/basics/class_inplace_op.py4
-rw-r--r--tests/basics/class_notimpl.py2
-rw-r--r--tests/basics/class_reverse_op.py2
-rw-r--r--tests/basics/string_repr.py2
5 files changed, 6 insertions, 6 deletions
diff --git a/tests/basics/async_await2.py b/tests/basics/async_await2.py
index 129d3751a..1e3164df9 100644
--- a/tests/basics/async_await2.py
+++ b/tests/basics/async_await2.py
@@ -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
diff --git a/tests/basics/class_inplace_op.py b/tests/basics/class_inplace_op.py
index 62aad8c7c..8885bdaa8 100644
--- a/tests/basics/class_inplace_op.py
+++ b/tests/basics/class_inplace_op.py
@@ -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
diff --git a/tests/basics/class_notimpl.py b/tests/basics/class_notimpl.py
index 7fd8166f9..308075f92 100644
--- a/tests/basics/class_notimpl.py
+++ b/tests/basics/class_notimpl.py
@@ -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)
diff --git a/tests/basics/class_reverse_op.py b/tests/basics/class_reverse_op.py
index d41c55c9d..b0dae5f8a 100644
--- a/tests/basics/class_reverse_op.py
+++ b/tests/basics/class_reverse_op.py
@@ -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))
diff --git a/tests/basics/string_repr.py b/tests/basics/string_repr.py
index 2a3ef2527..b4842e147 100644
--- a/tests/basics/string_repr.py
+++ b/tests/basics/string_repr.py
@@ -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))))