Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Lib/test/test_gettext.py
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
Member

Choose a reason for hiding this comment

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

Don't we need to tearDown this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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
Loading