GH-139862: Fix direct instantiation of HelpFormatter (#142384)

This commit is contained in:
Savannah Ostrowski 2025-12-07 13:02:12 -08:00 committed by GitHub
parent f193c8fe9e
commit dc9f2385ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View file

@ -5694,6 +5694,11 @@ def custom_formatter(prog):
a-very-long-command command that does something
'''))
def test_direct_formatter_instantiation(self):
formatter = argparse.HelpFormatter(prog="program")
formatter.add_usage(usage=None, actions=[], groups=[])
help_text = formatter.format_help()
self.assertEqual(help_text, "usage: program\n")
# =====================================
# Optional/Positional constructor tests