Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
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
base:main
Are you sure you want to change the base?
Conversation
Lib/test/test_gettext.py Outdated
returnmofile | ||
deftest_dgettext_found_translation(self): | ||
"""Test dgettext finds translation in specified domain.""" |
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.
Avoid using docstrings fortest_*
methods as it will be shown upon failure.
Lib/test/test_gettext.py Outdated
defsetUp(self): | ||
"""Set up a specific test domain and environment for dgettext tests.""" | ||
self.localedir=tempfile.mkdtemp() |
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.
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)
Lib/test/test_gettext.py Outdated
defsetUp(self): | ||
"""Set up a specific test domain and environment for dgettext tests.""" | ||
self.localedir=tempfile.mkdtemp() | ||
self.addCleanup(shutil.rmtree,self.localedir) |
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.
Prefer usingos_helper.rmtree
overshutil.rmtree
ecaa9d1
toc4fb7ac
CompareThere 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.
We can inherit fromGettextBaseTest
and avail of the mo files. You can then use the messages in the files to test it works properly.
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) |
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.
This could just be a for loop combining these cases.
Uh oh!
There was an error while loading.Please reload this page.
add tests for dgettext
dgettext
#134593gettext
#130655