-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-130197: Improve test coverage of msgfmt.py
part 2
#133309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Lib/test/test_tools/test_msgfmt.py
Outdated
msgfmt.MESSAGES.clear() | ||
with self.assertRaises((SystemExit, UnboundLocalError, | ||
IndexError, SyntaxError)): | ||
msgfmt.make('messages.po', 'messages.mo') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It prints errors on stderr. They should be silenced. Instead, it would be nice to check the output against the expected error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to capture the output and check error messages :)
Lib/test/test_tools/test_msgfmt.py
Outdated
'[0]', | ||
|
||
# unclosed string | ||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use textwrap.dedent()
and strip the initial newlines. It's up to you, but perhaps the indented code would look better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, I think it reads better with textwrap.dedent()
Lib/test/test_tools/test_msgfmt.py
Outdated
# invalid plural index | ||
# invalid but currently accepted | ||
# ''' | ||
# msgid "foo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think that it is worth to add such large blocks of the commented out code. It only increases the diff, in this PR, and in the future ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, I'll add them back (uncommented) when I fix the parser
This is a followup to #133048
This PR adds more tests to
msgfmt.py
:msgid
/msgstr
etc.., invalid plural indices and duplicate entries.I verified that these are rejected by GNU's
msgfmt
.Note that some tests are commented out. That is because
msgfmt.py
is currently accepting these as valid.In a followup PR, I am planning to fix its parser and then we'll be able to uncomment all of theses cases.