Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-130197: Improve test coverage ofmsgfmt.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
tomasr8 wants to merge7 commits intopython:main
base:main
Choose a base branch
Loading
fromtomasr8:msgfmt-parse-sem-errors

Conversation

tomasr8
Copy link
Member

@tomasr8tomasr8 commentedMay 2, 2025
edited by bedevere-appbot
Loading

This is a followup to#133048

This PR adds more tests tomsgfmt.py:

  • general syntax error tests (mainly unclosed strings and invalid plural syntax)
  • semantic errors such incorrect ordering ofmsgid/msgstr etc.., invalid plural indices and duplicate entries.

I verified that these are rejected by GNU'smsgfmt.

Note that some tests are commented out. That is becausemsgfmt.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.

@bedevere-appbedevere-appbot added the testsTests in the Lib/test dir labelMay 2, 2025
@bedevere-appbedevere-appbot mentioned this pull requestMay 2, 2025
18 tasks
msgfmt.MESSAGES.clear()
with self.assertRaises((SystemExit, UnboundLocalError,
IndexError, SyntaxError)):
msgfmt.make('messages.po', 'messages.mo')

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.

Copy link
MemberAuthor

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 :)

'[0]',

# unclosed string
'''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You could usetextwrap.dedent() and strip the initial newlines. It's up to you, but perhaps the indented code would look better.

tomasr8 reacted with thumbs up emoji
Copy link
MemberAuthor

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 withtextwrap.dedent()

# invalid plural index
# invalid but currently accepted
# '''
# msgid "foo"

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.

tomasr8 reacted with thumbs up emoji
Copy link
MemberAuthor

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@StanFromIrelandStanFromIrelandStanFromIreland left review comments

@serhiy-storchakaserhiy-storchakaAwaiting requested review from serhiy-storchaka

Assignees
No one assigned
Labels
awaiting reviewskip newstestsTests in the Lib/test dir
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@tomasr8@serhiy-storchaka@StanFromIreland

[8]ページ先頭

©2009-2025 Movatter.jp