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-130655: add tests for dgettext#134594

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
alex-semenyuk wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromalex-semenyuk:add_dgettext_tests

Conversation

alex-semenyuk
Copy link
Contributor

@alex-semenyukalex-semenyuk commentedMay 23, 2025
edited by bedevere-appbot
Loading

@bedevere-appbedevere-appbot added the testsTests in the Lib/test dir labelMay 23, 2025
returnmofile

deftest_dgettext_found_translation(self):
"""Test dgettext finds translation in specified domain."""
Copy link
Member

Choose a reason for hiding this comment

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

Avoid using docstrings fortest_* methods as it will be shown upon failure.


defsetUp(self):
"""Set up a specific test domain and environment for dgettext tests."""
self.localedir=tempfile.mkdtemp()
Copy link
Member

Choose a reason for hiding this comment

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

Instead of usingmkdtemp which would create something inside/tmp, usetest.support.temp_dir (I think, check the name) which creates something inside the build folder (it's easier to cleanup)

defsetUp(self):
"""Set up a specific test domain and environment for dgettext tests."""
self.localedir=tempfile.mkdtemp()
self.addCleanup(shutil.rmtree,self.localedir)
Copy link
Member

Choose a reason for hiding this comment

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

Prefer usingos_helper.rmtree overshutil.rmtree

Copy link
Contributor

@StanFromIrelandStanFromIreland left a comment

Choose a reason for hiding this comment

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

We can inherit fromGettextBaseTest and avail of the mo files. You can then use the messages in the files to test it works properly.

Comment on lines +965 to +972
deftest_dgettext_non_existent_domain(self):
result=gettext.dgettext('nonexistent_domain','test message')
self.assertEqual(result,'test message')

deftest_dgettext_empty_domain(self):
result=gettext.dgettext('','test message')
expected=gettext.gettext('test message')
self.assertEqual(result,expected)
Copy link
Contributor

Choose a reason for hiding this comment

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

This could just be a for loop combining these cases.

@picnixzpicnixz changed the titlegh-134593: add tests for dgettextgh-130655: add tests for dgettextMay 23, 2025
@picnixzpicnixz added needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsMay 23, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@picnixzpicnixzpicnixz left review comments

@StanFromIrelandStanFromIrelandStanFromIreland left review comments

Assignees
No one assigned
Labels
awaiting reviewneeds backport to 3.13bugs and security fixesneeds backport to 3.14bugs and security fixesskip newstestsTests in the Lib/test dir
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@alex-semenyuk@picnixz@StanFromIreland

[8]ページ先頭

©2009-2025 Movatter.jp