-
Notifications
You must be signed in to change notification settings - Fork 459
Check pofile string delimiters #1151
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Open
rtobar
wants to merge
7
commits into
python-babel:master
Choose a base branch
from
rtobar:check-string-delimiters
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
913feaa
Avoid re-compiling regular expression
rtobar 3647ae8
Remove duplicate test assertion
rtobar 5e84dc6
Perform full intended assertion in test
rtobar 663f97e
Clarify usage of of _NormalizeString
rtobar 5f09192
Add further msgstr plural checks
rtobar 00062fb
Detect incorrectly delimited strings
rtobar ff5213b
Formalise constraint on _NormalizeString's inputs
rtobar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,43 @@ | ||
import pytest | ||
|
||
from babel.messages.pofile import _NormalizedString | ||
|
||
|
||
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]) # the sort order is not stable so we can't really check it, just that we can sort | ||
assert sorted([ac, ab, z]) == [z, ab, ac] # sorted() is stable | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"original, denormalized", | ||
( | ||
('""', ""), | ||
('"a"', "a"), | ||
('"a\\n"', "a\n"), | ||
('"a\\r"', "a\r"), | ||
('"a\\t"', "a\t"), | ||
('"a\\""', 'a"'), | ||
('"a\\\\"', "a\\"), | ||
), | ||
) | ||
def test_denormalized_simple_normalized_string(original, denormalized): | ||
assert denormalized == _NormalizedString(original).denormalize() | ||
|
||
@pytest.mark.parametrize( | ||
"originals, denormalized", | ||
( | ||
(('"a"', '"b"'), "ab"), | ||
(('"a"', '"b"'), "ab"), | ||
(('"ab"', '""'), "ab"), | ||
(('"ab"', '"c"'), "abc"), | ||
(('"a"', '"bc"'), "abc"), | ||
), | ||
) | ||
def test_denormalized_multi_normalized_string(originals, denormalized): | ||
assert denormalized == _NormalizedString(*originals).denormalize() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.