diff options
author | Ćukasz Langa <lukasz@langa.pl> | 2025-05-05 21:45:25 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-05 21:45:25 (GMT) |
commit | f610bbdf74ea580b14353c6bfd08fd00bcbfa11e (patch) | |
tree | 5755794c7c8f2e4c14ad4be9665499311b4db17b /Lib/test/test_argparse.py | |
parent | 9cc77aaf9dce6ffa82786dc77f7f83387c857cad (diff) | |
download | cpython-f610bbdf74ea580b14353c6bfd08fd00bcbfa11e.zip cpython-f610bbdf74ea580b14353c6bfd08fd00bcbfa11e.tar.gz cpython-f610bbdf74ea580b14353c6bfd08fd00bcbfa11e.tar.bz2 |
gh-133346: Make theming support in _colorize extensible (GH-133347)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r-- | Lib/test/test_argparse.py | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index c5a1f31..5a6be11 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -7058,7 +7058,7 @@ class TestColorized(TestCase): super().setUp() # Ensure color even if ran with NO_COLOR=1 _colorize.can_colorize = lambda *args, **kwargs: True - self.ansi = _colorize.ANSIColors() + self.theme = _colorize.get_theme(force_color=True).argparse def test_argparse_color(self): # Arrange: create a parser with a bit of everything @@ -7120,13 +7120,17 @@ class TestColorized(TestCase): sub2 = subparsers.add_parser("sub2", deprecated=True, help="sub2 help") sub2.add_argument("--baz", choices=("X", "Y", "Z"), help="baz help") - heading = self.ansi.BOLD_BLUE - label, label_b = self.ansi.YELLOW, self.ansi.BOLD_YELLOW - long, long_b = self.ansi.CYAN, self.ansi.BOLD_CYAN - pos, pos_b = short, short_b = self.ansi.GREEN, self.ansi.BOLD_GREEN - sub = self.ansi.BOLD_GREEN - prog = self.ansi.BOLD_MAGENTA - reset = self.ansi.RESET + prog = self.theme.prog + heading = self.theme.heading + long = self.theme.summary_long_option + short = self.theme.summary_short_option + label = self.theme.summary_label + pos = self.theme.summary_action + long_b = self.theme.long_option + short_b = self.theme.short_option + label_b = self.theme.label + pos_b = self.theme.action + reset = self.theme.reset # Act help_text = parser.format_help() @@ -7171,9 +7175,9 @@ class TestColorized(TestCase): {heading}subcommands:{reset} valid subcommands - {sub}{{sub1,sub2}}{reset} additional help - {sub}sub1{reset} sub1 help - {sub}sub2{reset} sub2 help + {pos_b}{{sub1,sub2}}{reset} additional help + {pos_b}sub1{reset} sub1 help + {pos_b}sub2{reset} sub2 help """ ), ) @@ -7187,10 +7191,10 @@ class TestColorized(TestCase): prog="PROG", usage="[prefix] %(prog)s [suffix]", ) - heading = self.ansi.BOLD_BLUE - prog = self.ansi.BOLD_MAGENTA - reset = self.ansi.RESET - usage = self.ansi.MAGENTA + heading = self.theme.heading + prog = self.theme.prog + reset = self.theme.reset + usage = self.theme.prog_extra # Act help_text = parser.format_help() |