Skip to content

Commit bcb03ac

Browse files
committed
python-stdlib/unittest/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 be 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 bcb03ac

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

python-stdlib/unittest/unittest/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ def __exit__(self, *exc_info):
4949
global __test_result__, __current_test__
5050
test_details = __current_test__
5151
if self.msg:
52-
test_details += (f" [{self.msg}]",)
52+
test_details += (" [%s]" % self.msg,)
5353
if self.params:
54-
detail = ", ".join(f"{k}={v}" for k, v in self.params.items())
55-
test_details += (f" ({detail})",)
54+
detail = ", ".join("%s=%s" % (k, v) for k, v in self.params.items())
55+
test_details += (" (%s)" % detail,)
5656

5757
_handle_test_exception(test_details, __test_result__, exc_info, False)
5858
# Suppress the exception as we've captured it above
@@ -310,7 +310,7 @@ def printErrorList(self, lst):
310310
for c, e in lst:
311311
detail = " ".join((str(i) for i in c))
312312
print("======================================================================")
313-
print(f"FAIL: {detail}")
313+
print("FAIL: %s" % detail)
314314
print(sep)
315315
print(e)
316316

@@ -391,7 +391,7 @@ def run_one(test_function):
391391
print("%s (%s) ..." % (name, suite_name), end="")
392392
set_up()
393393
__test_result__ = test_result
394-
test_container = f"({suite_name})"
394+
test_container = "(%s)" % suite_name
395395
__current_test__ = (name, test_container)
396396
try:
397397
test_result._newFailures = 0

0 commit comments

Comments
 (0)