mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
GH-139862: Fix direct instantiation of HelpFormatter (#142384)
This commit is contained in:
parent
f193c8fe9e
commit
dc9f2385ed
2 changed files with 7 additions and 0 deletions
|
|
@ -189,6 +189,8 @@ def __init__(
|
||||||
self._whitespace_matcher = _re.compile(r'\s+', _re.ASCII)
|
self._whitespace_matcher = _re.compile(r'\s+', _re.ASCII)
|
||||||
self._long_break_matcher = _re.compile(r'\n\n\n+')
|
self._long_break_matcher = _re.compile(r'\n\n\n+')
|
||||||
|
|
||||||
|
self._set_color(False)
|
||||||
|
|
||||||
def _set_color(self, color):
|
def _set_color(self, color):
|
||||||
from _colorize import can_colorize, decolor, get_theme
|
from _colorize import can_colorize, decolor, get_theme
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5694,6 +5694,11 @@ def custom_formatter(prog):
|
||||||
a-very-long-command command that does something
|
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
|
# Optional/Positional constructor tests
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue