mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
fix: translations not containing string formatting
In some translations we might be missing replacement placeholders (%). This turns out to be problematic when calling the format function. Wrap the jinja2 format function and just return the string unformatted when % is missing. Fixes: #341 Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
parent
c0bbe21d81
commit
fa1212f2de
2 changed files with 32 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
from datetime import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
import pytest
|
||||
|
||||
from aurweb import filters, time
|
||||
|
||||
|
||||
|
@ -34,3 +36,18 @@ def test_to_qs():
|
|||
query = {"a": "b", "c": [1, 2, 3]}
|
||||
qs = filters.to_qs(query)
|
||||
assert qs == "a=b&c=1&c=2&c=3"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"value, args, expected",
|
||||
[
|
||||
("", (), ""),
|
||||
("a", (), "a"),
|
||||
("a", (1,), "a"),
|
||||
("%s", ("a",), "a"),
|
||||
("%s", ("ab",), "ab"),
|
||||
("%s%d", ("a", 1), "a1"),
|
||||
],
|
||||
)
|
||||
def test_safe_format(value: str, args: tuple, expected: str):
|
||||
assert filters.safe_format(value, *args) == expected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue