Skip to content

Commit 816d952

Browse files
agattidpgeorge
authored andcommitted
unittest: Remove f-strings.
This commit removes usage of f-strings from the unittest module, in favour to the old printf-style raw string formatting operations. The module is a bit special since it is meant to also validate the behaviour of MicroPython interpreters, and those may come with any combination of configuration options. For example, f-strings are not available by default on some feature levels, and thus the test suite won't run cleanly on certain targets unless the support for that feature is explicitly enabled. See the discussion at micropython/micropython#19111 for more information. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
1 parent 2d6dc2f commit 816d952

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

python-stdlib/unittest/manifest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.10.4")
1+
metadata(version="0.10.5")
22

33
package("unittest")

python-stdlib/unittest/unittest/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import io
2-
import os
32
import sys
43

54
try:
@@ -49,10 +48,10 @@ def __exit__(self, *exc_info):
4948
global __test_result__, __current_test__
5049
test_details = __current_test__
5150
if self.msg:
52-
test_details += (f" [{self.msg}]",)
51+
test_details += (" [%s]" % self.msg,)
5352
if self.params:
54-
detail = ", ".join(f"{k}={v}" for k, v in self.params.items())
55-
test_details += (f" ({detail})",)
53+
detail = ", ".join("%s=%s" % k_v for k_v in self.params.items())
54+
test_details += (" (%s)" % detail,)
5655

5756
_handle_test_exception(test_details, __test_result__, exc_info, False)
5857
# Suppress the exception as we've captured it above
@@ -310,7 +309,7 @@ def printErrorList(self, lst):
310309
for c, e in lst:
311310
detail = " ".join((str(i) for i in c))
312311
print("======================================================================")
313-
print(f"FAIL: {detail}")
312+
print("FAIL:", detail)
314313
print(sep)
315314
print(e)
316315

@@ -391,7 +390,7 @@ def run_one(test_function):
391390
print("%s (%s) ..." % (name, suite_name), end="")
392391
set_up()
393392
__test_result__ = test_result
394-
test_container = f"({suite_name})"
393+
test_container = "(%s)" % suite_name
395394
__current_test__ = (name, test_container)
396395
try:
397396
test_result._newFailures = 0

0 commit comments

Comments
 (0)