[ruff UP031] Fix to use format specifiers instead of percent format

This commit is contained in:
Pierre Sassoulas
2024-04-30 18:06:26 +02:00
parent da53e29780
commit 4788165e69
52 changed files with 202 additions and 212 deletions

View File

@@ -1421,7 +1421,7 @@ def test_tbstyle_short(pytester: Pytester) -> None:
s = result.stdout.str()
assert "arg = 42" not in s
assert "x = 0" not in s
result.stdout.fnmatch_lines(["*%s:8*" % p.name, " assert x", "E assert*"])
result.stdout.fnmatch_lines([f"*{p.name}:8*", " assert x", "E assert*"])
result = pytester.runpytest()
s = result.stdout.str()
assert "x = 0" in s
@@ -1497,8 +1497,8 @@ class TestGenericReporting:
"""
)
for tbopt in ["long", "short", "no"]:
print("testing --tb=%s..." % tbopt)
result = pytester.runpytest("-rN", "--tb=%s" % tbopt)
print(f"testing --tb={tbopt}...")
result = pytester.runpytest("-rN", f"--tb={tbopt}")
s = result.stdout.str()
if tbopt == "long":
assert "print(6*7)" in s
@@ -1528,7 +1528,7 @@ class TestGenericReporting:
result = pytester.runpytest("--tb=line")
bn = p.name
result.stdout.fnmatch_lines(
["*%s:3: IndexError*" % bn, "*%s:8: AssertionError: hello*" % bn]
[f"*{bn}:3: IndexError*", f"*{bn}:8: AssertionError: hello*"]
)
s = result.stdout.str()
assert "def test_func2" not in s
@@ -1544,7 +1544,7 @@ class TestGenericReporting:
result = pytester.runpytest("--tb=line")
result.stdout.str()
bn = p.name
result.stdout.fnmatch_lines(["*%s:3: Failed: test_func1" % bn])
result.stdout.fnmatch_lines([f"*{bn}:3: Failed: test_func1"])
def test_pytest_report_header(self, pytester: Pytester, option) -> None:
pytester.makeconftest(
@@ -1945,7 +1945,7 @@ def test_summary_stats(
# Reset cache.
tr._main_color = None
print("Based on stats: %s" % stats_arg)
print(f"Based on stats: {stats_arg}")
print(f'Expect summary: "{exp_line}"; with color "{exp_color}"')
(line, color) = tr.build_summary_stats_line()
print(f'Actually got: "{line}"; with color "{color}"')