From bf44f19c1de86c4cf163955f2510aa1e26767e49 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 9 Jan 2024 08:16:37 -0600 Subject: [PATCH] Avoid py f-strings to support py < 3.6. --- test/BoostBuild.py | 10 +++++----- test/test_all.py | 8 ++++---- test/tree.py | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/BoostBuild.py b/test/BoostBuild.py index 07ae053f20..3942c00567 100644 --- a/test/BoostBuild.py +++ b/test/BoostBuild.py @@ -393,7 +393,7 @@ def write(self, file, content, wait=True): with open(nfile, "wb") as f: f.write(content) except Exception as e: - annotation("failure", f"Could not create file '{nfile}': {e}") + annotation("failure","Could not create file '{}': {}".format(nfile, e)) annotate_stack_trace(level=3) self.fail_test(1) self.__ensure_newer_than_last_build(nfile) @@ -580,11 +580,11 @@ def do_diff(self, what, actual, expected, matcher, match_filter): if match: return diff = "".join(ndiff(expected_lines, actual_lines)) - annotation(f"Expected {what}", expected) - annotation(f"Actual {what}", actual) + annotation("Expected {}".format(what), expected) + annotation("Actual {}".format(what), actual) if what.lower() == "stdout": annotation("STDERR", self.stderr()) - annotation(f"Difference in {what}{filtered}", diff) + annotation("Difference in {}{}".format(what, filtered), diff) self.fail_test(True, dump_stdio=False) def glob_file(self, name): @@ -1059,7 +1059,7 @@ def __makedirs(self, path, wait): else: os.makedirs(path, exist_ok=True) except Exception as e: - annotation("failure", f"Could not create path '{path}': {e}") + annotation("failure", "Could not create path '{}': {}".format(path, e)) annotate_stack_trace(level=3) self.fail_test(1) diff --git a/test/test_all.py b/test/test_all.py index a5f1d84338..98dd557d5d 100755 --- a/test/test_all.py +++ b/test/test_all.py @@ -94,7 +94,7 @@ def handler(sig, frame): if not xml: s = "%%-%ds :" % max_test_name_len % test if isatty: - s = f"\r{s}" + s = "\r{}".format(s) print(s, end='') passed = 0 @@ -148,15 +148,15 @@ def handler(sig, frame): if not xml: if passed: - print(f"PASSED {ts * 1000:>5.0f}ms") + print("PASSED {:>5.0f}ms".format(ts*1000)) else: - print(f"FAILED {ts * 1000:>5.0f}ms") + print("FAILED {:>5.0f}ms".format(ts*1000)) BoostBuild.flush_annotations() if isatty: msg = ", ".join(futures[future] for future in pending if future.running()) if msg: - msg = f"[{len(futures) - len(pending)}/{len(futures)}] {msg}" + msg = "[{}/{}] {}".format(len(futures) - len(pending),len(futures),msg) max_len = max_test_name_len + len(" :PASSED 12345ms") if len(msg) > max_len: msg = msg[:max_len - 3] + "..." diff --git a/test/tree.py b/test/tree.py index 73ade95102..87c12d4784 100644 --- a/test/tree.py +++ b/test/tree.py @@ -113,7 +113,7 @@ def _pprint_filelist(names): s = repr(names) if len(s) < 70: return s - return "".join(f"\n - {name}" for name in names) + return "".join("\n - {}".format(name) for name in names) def pprint(self, file=sys.stdout): file.write("Added files : %s\n" % self._pprint_filelist(self.added_files))