From 6ade02b2340e37b034d3db61f79d4cb4ba8fb1ea Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 17 May 2022 16:40:30 +0200 Subject: [PATCH] Use f-strings when possible --- tests/draw/__init__.py | 4 ++-- tests/test_api.py | 10 +++++----- tests/test_text.py | 4 ++-- tests/test_unicode.py | 2 +- weasyprint/svg/bounding_box.py | 6 +++--- weasyprint/svg/path.py | 6 +++--- weasyprint/text/line_break.py | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/draw/__init__.py b/tests/draw/__init__.py index e11953a5..0e9c4271 100644 --- a/tests/draw/__init__.py +++ b/tests/draw/__init__.py @@ -96,7 +96,7 @@ def write_png(basename, pixels, width, height): # pragma: no cover directory = os.path.join(os.path.dirname(__file__), 'results') if not os.path.isdir(directory): os.mkdir(directory) - filename = os.path.join(directory, basename + '.png') + filename = os.path.join(directory, f'{basename}.png') image = Image.new('RGB', (width, height)) image.putdata(pixels) image.save(filename) @@ -135,7 +135,7 @@ def assert_pixels_equal(name, width, height, raw, expected_raw, tolerance=0): write_png(name, raw, width, actual_height) expected_raw = [ pixel or (255, 255, 255) for pixel in expected_raw] - write_png(name + '.expected', expected_raw, width, height) + write_png(f'{name}.expected', expected_raw, width, height) x = i % width y = i // width assert 0, ( diff --git a/tests/test_api.py b/tests/test_api.py index a42e4aaf..2f54e579 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -327,10 +327,10 @@ def test_command_line_render(tmpdir): _run('combined-UTF-16BE.html out3.pdf --encoding UTF-16BE') assert tmpdir.join('out3.pdf').read_binary() == pdf_bytes - _run(tmpdir.join('combined.html').strpath + ' out4.pdf') + _run(f'{tmpdir.join("combined.html").strpath} out4.pdf') assert tmpdir.join('out4.pdf').read_binary() == pdf_bytes - _run(path2url(tmpdir.join('combined.html').strpath) + ' out5.pdf') + _run(f'{path2url(tmpdir.join("combined.html").strpath)} out5.pdf') assert tmpdir.join('out5.pdf').read_binary() == pdf_bytes _run('linked.html --debug out6.pdf') # test relative URLs @@ -1036,10 +1036,10 @@ def test_http(): (b'', []) ), }) as root_url: - assert HTML(root_url + '/gzip').etree_element.get('test') == 'ok' - assert HTML(root_url + '/deflate').etree_element.get('test') == 'ok' + assert HTML(f'{root_url}/gzip').etree_element.get('test') == 'ok' + assert HTML(f'{root_url}/deflate').etree_element.get('test') == 'ok' assert HTML( - root_url + '/raw-deflate').etree_element.get('test') == 'ok' + f'{root_url}/raw-deflate').etree_element.get('test') == 'ok' @assert_no_logs diff --git a/tests/test_text.py b/tests/test_text.py index 41527359..81115f8e 100644 --- a/tests/test_text.py +++ b/tests/test_text.py @@ -707,7 +707,7 @@ def test_hyphenate_character_5(): @pytest.mark.parametrize('i', (range(1, len('hyphénation')))) def test_hyphenate_manual_1(i): for hyphenate_character in ('!', 'ù ù'): - word = 'hyphénation'[:i] + '\xad' + 'hyphénation'[i:] + word = f'{"hyphénation"[:i]}\xad{"hyphénation"[i:]}' page, = render_pages( '' '