Skip to content

Commit e4de3fc

Browse files
committed
fix(tests): Adapt CmdlineSuite to default to non-pretty output
This commit adapts the `CmdlineSuite` runner to handle the new pretty-by-default behavior. The `parse_args` helper in `mypy/test/testcmdline.py` is modified to inject the `--no-pretty` flag into the arguments parsed from '# cmd:' lines in test cases. This ensures that command-line-driven tests, which run in a separate subprocess and bypass other test helpers, are also executed in non-pretty mode by default. Part of #19108.
1 parent 56fb7da commit e4de3fc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mypy/test/testcmdline.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,13 @@ def parse_args(line: str) -> list[str]:
131131
"""
132132
m = re.match("# cmd: mypy (.*)$", line)
133133
if not m:
134-
return [] # No args; mypy will spit out an error.
135-
return m.group(1).split()
134+
return ['--no-pretty'] # No args; mypy will spit out an error.
135+
args = m.group(1).split()
136+
137+
if '--pretty' not in args:
138+
args.append('--no-pretty')
139+
140+
return args
136141

137142

138143
def parse_cwd(line: str) -> str | None:

0 commit comments

Comments
 (0)