Skip to content

Commit feb6aec

Browse files
Use line breaks FTW in output directive error message
1 parent 42a900a commit feb6aec

2 files changed

Lines changed: 22 additions & 9 deletions

File tree

‎Lib/test/test_clinic.py‎

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -634,13 +634,24 @@ def test_directive_preserve_output(self):
634634
self.assertEqual(generated, block)
635635

636636
def test_directive_output_invalid_command(self):
637-
err = (
638-
"Invalid command / destination name 'cmd', must be one of:\n"
639-
"preset push pop print everything cpp_if docstring_prototype "
640-
"docstring_definition methoddef_define impl_prototype "
641-
"parser_prototype parser_definition cpp_endif methoddef_ifndef "
642-
"impl_definition"
643-
)
637+
err = dedent("""
638+
Invalid command or destination name 'cmd'. Must be one of:
639+
- preset
640+
- push
641+
- pop
642+
- print
643+
- everything
644+
- cpp_if
645+
- docstring_prototype
646+
- docstring_definition
647+
- methoddef_define
648+
- impl_prototype
649+
- parser_prototype
650+
- parser_definition
651+
- cpp_endif
652+
- methoddef_ifndef
653+
- impl_definition
654+
""").strip()
644655
block = """
645656
/*[clinic input]
646657
output cmd buffer

‎Tools/clinic/clinic.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4567,8 +4567,10 @@ def directive_output(
45674567
return
45684568

45694569
if command_or_name not in fd:
4570-
fail(f"Invalid command / destination name {command_or_name!r}, must be one of:\n"
4571-
"preset push pop print everything", " ".join(fd))
4570+
allowed = ["preset", "push", "pop", "print", "everything"]
4571+
allowed.extend(fd)
4572+
fail(f"Invalid command or destination name {command_or_name!r}. "
4573+
"Must be one of:\n -", "\n - ".join(allowed))
45724574
fd[command_or_name] = d
45734575

45744576
def directive_dump(self, name: str) -> None:

0 commit comments

Comments
 (0)