diff --git a/babel/messages/pofile.py b/babel/messages/pofile.py index 57b038883..5d7c80e8c 100644 --- a/babel/messages/pofile.py +++ b/babel/messages/pofile.py @@ -144,7 +144,8 @@ def __init__(self, *args: str) -> None: self.append(arg) def append(self, s: str) -> None: - self._strs.append(s.strip()) + assert s[0] == '"' and s[-1] == '"' + self._strs.append(s) def denormalize(self) -> str: return ''.join(map(unescape, self._strs)) diff --git a/tests/messages/test_normalized_string.py b/tests/messages/test_normalized_string.py index 735603770..f398a1680 100644 --- a/tests/messages/test_normalized_string.py +++ b/tests/messages/test_normalized_string.py @@ -4,19 +4,14 @@ def test_normalized_string(): - ab1 = _NormalizedString('"a"', '"b" ') - ab2 = _NormalizedString('"a"', ' "b"') - ac1 = _NormalizedString('"a"', '"c"') - ac2 = _NormalizedString(' "a"', '"c" ') + ab = _NormalizedString('"a"', '"b"') + ac = _NormalizedString('"a"', '"c"') z = _NormalizedString() - assert ab1 == ab2 and ac1 == ac2 # __eq__ - assert ab1 < ac1 # __lt__ - assert ac1 > ab2 # __gt__ - assert ac1 >= ac2 # __ge__ - assert ab1 <= ab2 # __le__ - assert ab1 != ac1 # __ne__ + assert ab < ac # __lt__ + assert ac > ab # __gt__ + assert ab != ac # __ne__ assert not z # __nonzero__ / __bool__ - assert sorted([ab1, ab2, ac1]) == [ab1, ab2, ac1] # sorted() is stable + assert sorted([ac, ab, z]) == [z, ab, ac] # sorted() is stable @pytest.mark.parametrize( @@ -38,10 +33,10 @@ def test_denormalized_simple_normalized_string(original, denormalized): "originals, denormalized", ( (('"a"', '"b"'), "ab"), - (('"a" ', '"b"'), "ab"), + (('"a"', '"b"'), "ab"), (('"ab"', '""'), "ab"), (('"ab"', '"c"'), "abc"), - (('"a"', ' "bc"'), "abc"), + (('"a"', '"bc"'), "abc"), ), ) def test_denormalized_multi_normalized_string(originals, denormalized):