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-124295: Add translation tests for argparse#124803

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

Merged
serhiy-storchaka merged 12 commits intopython:mainfromtomasr8:argparse-tests
Oct 27, 2024

Conversation

@tomasr8
Copy link
Member

@tomasr8tomasr8 commentedSep 30, 2024
edited by bedevere-appbot
Loading

This usesTools/i18n/pygettext.py to extract all translatable messages fromargparse.py. The messages are kept in a snapshot file in the test folder. The test extracts the current messages and compares them against this snapshot.

The snapshot can be updated using./python Lib/test/test_argparse/test_translations.py --snapshot-update.

There is currently no way to read a PO file using the stdlib (gettext only reads MO files, maybe it should be able to do both?) so I just use a simple regex to get themsgids out of the PO file.

Feedback welcome!

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you,@tomasr8.

Since argparse is currently actively fixed, there are some conflicts. After fixing them I'll merge this PR.

tomasr8 reacted with hooray emoji
@serhiy-storchakaserhiy-storchaka added testsTests in the Lib/test dir needs backport to 3.12only security fixes needs backport to 3.13bugs and security fixes labelsOct 1, 2024
@serhiy-storchaka
Copy link
Member

I will wait for the 3.13 release before merging this PR because it will conflict with many backports waiting for 3.13. It would be easier to resolve conflicts in this PR (just movetest_argparse.py) than in other PRs which modify the part of the file.

@serhiy-storchakaserhiy-storchaka self-assigned thisOct 2, 2024
@tomasr8
Copy link
MemberAuthor

I will wait for the 3.13 release before merging this PR because it will conflict with many backports waiting for 3.13. It would be easier to resolve conflicts in this PR (just movetest_argparse.py) than in other PRs which modify the part of the file.

Ok! Let me know if I can help with anything :)

@serhiy-storchaka
Copy link
Member

Don't worry, I'll merge this PR when the time comes.

tomasr8 reacted with thumbs up emoji

@tomasr8
Copy link
MemberAuthor

Don't worry, I'll merge this PR when the time comes.

Github was complaining about some merge conflicts so I just wanted to update the branch ;)

@savannahostrowskisavannahostrowski linked an issueOct 18, 2024 that may beclosed by this pull request
This avoids having to turn tests into packages.
@tomasr8
Copy link
MemberAuthor

On Serhiy's suggestion, I moved the translation data into a separate folder and merged the new tests with the existing ones to avoid turning the tests into a package.

erlend-aasland reacted with thumbs up emoji

@serhiy-storchakaserhiy-storchaka merged commit0922a4a intopython:mainOct 27, 2024
35 checks passed
@miss-islington-app
Copy link

Thanks@tomasr8 for the PR, and@serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry,@tomasr8 and@serhiy-storchaka, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 0922a4ae0d2803e3a4e9f3d2ccd217364cfd700e 3.13

@miss-islington-app
Copy link

Sorry,@tomasr8 and@serhiy-storchaka, I could not cleanly backport this to3.12 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker 0922a4ae0d2803e3a4e9f3d2ccd217364cfd700e 3.12

@bedevere-app
Copy link

GH-126046 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelOct 27, 2024
@serhiy-storchakaserhiy-storchaka removed the needs backport to 3.12only security fixes labelOct 27, 2024
@serhiy-storchakaserhiy-storchaka removed their assignmentOct 27, 2024
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull requestOct 27, 2024
…124803)(cherry picked from commit0922a4a)Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
@tomasr8
Copy link
MemberAuthor

tomasr8 commentedOct 27, 2024
edited
Loading

There seems to be a buildbot failure related to this PR:https://buildbot.python.org/#/builders/1244/builds/3363
I think it's because scripts are not always included in python installations. We'll probably need to guard the test withskip_if_missing.

Edit: maybe something like this?

  @requires_subprocess()+ @requires_tool('i18n')  class TestTranslations(unittest.TestCase):

with this helper function intest_tools?

defrequires_tool(tool=None):exists=Truetry:skip_if_missing(tool)exceptunittest.SkipTest:exists=Falsereturnunittest.skipUnless(exists,f'{tool} not available')
serhiy-storchaka reacted with thumbs up emoji

@serhiy-storchaka
Copy link
Member

serhiy-storchaka commentedOct 27, 2024
edited
Loading

Do you mind to create a PR? I paused backporting.

Simply callskip_if_missing() in the test. Or insetUpClass() if there were several tests.

tomasr8 reacted with thumbs up emoji

@tomasr8
Copy link
MemberAuthor

Do you mind to create a PR? I paused backporting.

Simply callskip_if_missing() in the test. Or insetUpClass() if there were several tests.

On it :)

@tomasr8
Copy link
MemberAuthor

PR is here:#126051

@tomasr8tomasr8 deleted the argparse-tests branchOctober 27, 2024 17:45
serhiy-storchaka added a commit that referenced this pull requestOct 27, 2024
…126046)(cherry picked from commit0922a4a)Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this pull requestOct 27, 2024
…thonGH-124803) (pythonGH-126046)(cherry picked from commit0922a4a)(cherry picked from commitff044ed)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
serhiy-storchaka added a commit that referenced this pull requestOct 27, 2024
…126046) (GH-126054)(cherry picked from commit0922a4a)(cherry picked from commitff044ed)Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
picnixz pushed a commit to picnixz/cpython that referenced this pull requestDec 8, 2024
ebonnal pushed a commit to ebonnal/cpython that referenced this pull requestJan 12, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@erlend-aaslanderlend-aaslanderlend-aasland approved these changes

Assignees

No one assigned

Labels

testsTests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Add translation tests for argparse

3 participants

@tomasr8@serhiy-storchaka@erlend-aasland

[8]ページ先頭

©2009-2025 Movatter.jp