Skip to content

Commit

Permalink
fix test_bad_action after CPython change
Browse files Browse the repository at this point in the history
  • Loading branch information
FriedrichFroebel committed Dec 15, 2024
1 parent 2ea1e11 commit be81810
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,24 +217,19 @@ def test_bad_action(self, action='eggs'):
parser.parse_arguments(dict())
self.assertEqual(exception_manager.exception.args, (2,))
action_values = ','.join(self.action_names)
if sys.version_info < (3, 12):
if sys.version_info < (3, 12, 8):
# This unfortunately has been changed in a patch release:
# https://github.com/python/cpython/commit/21524eec48f5b1c807f185253e9350cfdd897ce0
action_strings = ', '.join(map(repr, self.action_names))
self.assertMultiLineEqual(
stderr.getvalue(),
(
f'usage: didjvu [-h] [--version] {{{action_values}}} ...\n'
f"didjvu: error: argument {{{action_values}}}: invalid choice: 'eggs' (choose from {action_strings})\n"
)
)
else:
action_strings = ', '.join(map(lambda x: f"'{x}'", self.action_names))
self.assertMultiLineEqual(
stderr.getvalue(),
(
f'usage: didjvu [-h] [--version] {{{action_values}}} ...\n'
f"didjvu: error: argument {{{action_values}}}: invalid choice: 'eggs' (choose from {action_strings})\n"
)
)
action_strings = ', '.join(map(str, self.action_names))
self.assertMultiLineEqual(
(
f'usage: didjvu [-h] [--version] {{{action_values}}} ...\n'
f"didjvu: error: argument {{{action_values}}}: invalid choice: 'eggs' (choose from {action_strings})\n"
),
stderr.getvalue(),
)

def _test_action(self, action, *args):
stderr = io.StringIO()
Expand Down

0 comments on commit be81810

Please sign in to comment.