FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-130655: add tests for dgettext by alex-semenyuk · Pull Request #134594 · python/cpython · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
22 changes: 22 additions & 0 deletions Lib/test/test_gettext.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,28 @@ def test_lazy_import(self):
ensure_lazy_imports("gettext", {"re", "warnings", "locale"})


class DGettextTest(GettextBaseTest):

def setUp(self):
super().setUp()
gettext.bindtextdomain('gettext', os.curdir)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Don't we need to tearDown this one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Seems reset_gettext() resets the state from GettextBaseTest is enough


def test_dgettext_translation(self):
translation_cases = [
('gettext', 'mullusk', 'bacon'),
('gettext', 'Raymond Luxury Yach-t', 'Throatwobbler Mangrove'),
('gettext', 'nudge nudge', 'wink wink'),

('gettext', 'missing message', 'missing message'),
('nonexistent_domain', 'mullusk', 'mullusk'),
('', 'mullusk', gettext.gettext('mullusk')),
]
for domain, msgid, expected in translation_cases:
with self.subTest(domain=domain, msgid=msgid):
result = gettext.dgettext(domain, msgid)
self.assertEqual(result, expected)


if __name__ == '__main__':
unittest.main()

Expand Down

Back | FazBrowse Home | New Git URL