Skip to content

gh-129911: pygettext: Fix the keyword entry in help output #129914

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions Lib/test/test_tools/test_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ def test_files_list(self):
self.assertIn(f'msgid "{text2}"', data)
self.assertNotIn(text3, data)

def test_help_text(self):
"""Test that the help text is displayed."""
res = assert_python_ok(self.script, '--help')
self.assertEqual(res.out, b'')
self.assertIn(b'pygettext -- Python equivalent of xgettext(1)', res.err)
Copy link
Member Author

Choose a reason for hiding this comment

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

I only test that the --help argument works, not that the help text matches a snapshot exactly, though I can add it


def test_error_messages(self):
"""Test that pygettext outputs error messages to stderr."""
stderr = self.get_stderr(dedent('''\
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix the keyword entry in the help output of :program:`pygettext`.
5 changes: 3 additions & 2 deletions Tools/i18n/pygettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
-k word
--keyword=word
Keywords to look for in addition to the default set, which are:
%(DEFAULTKEYWORDS)s
_, gettext, ngettext, pgettext, npgettext, dgettext, dngettext,
dpgettext, and dnpgettext.

You can have multiple -k flags on the command line.

Expand Down Expand Up @@ -169,7 +170,7 @@


def usage(code, msg=''):
print(__doc__ % globals(), file=sys.stderr)
print(__doc__, file=sys.stderr)
if msg:
print(msg, file=sys.stderr)
sys.exit(code)
Expand Down
Loading