gh-129911: pygettext: Fix the keyword entry in help output (GH-129914)

This commit is contained in:
Tomas R. 2025-02-14 10:34:09 +01:00 committed by GitHub
parent 3bd3e09588
commit 9d1e668e6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View file

@ -413,6 +413,12 @@ class Test_pygettext(unittest.TestCase):
self.assertIn(f'msgid "{text2}"', data) self.assertIn(f'msgid "{text2}"', data)
self.assertNotIn(text3, 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)
def test_error_messages(self): def test_error_messages(self):
"""Test that pygettext outputs error messages to stderr.""" """Test that pygettext outputs error messages to stderr."""
stderr = self.get_stderr(dedent('''\ stderr = self.get_stderr(dedent('''\

View file

@ -0,0 +1 @@
Fix the keyword entry in the help output of :program:`pygettext`.

View file

@ -67,7 +67,8 @@ Options:
-k word -k word
--keyword=word --keyword=word
Keywords to look for in addition to the default set, which are: 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. You can have multiple -k flags on the command line.
@ -169,7 +170,7 @@ msgstr ""
def usage(code, msg=''): def usage(code, msg=''):
print(__doc__ % globals(), file=sys.stderr) print(__doc__, file=sys.stderr)
if msg: if msg:
print(msg, file=sys.stderr) print(msg, file=sys.stderr)
sys.exit(code) sys.exit(code)