Skip to content

Commit 9940678

Browse files
committed
fix(tests): Update Stubtest unit tests to expect pretty output
This commit adapts several unit tests in the `StubtestMiscUnit` suite to handle the new pretty-by-default behavior. Because the `stubtest` runner is a distinct command-line tool, injecting the `--no-pretty` flag was not feasible as it's an unrecognized argument. Instead, the `assert` statements in the failing tests have been updated to match the new, pretty-printed error output from mypy. Part of #19108.
1 parent 6a0a7c2 commit 9940678

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mypy/test/teststubtest.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,13 +2581,17 @@ def test_mypy_build(self) -> None:
25812581
output = run_stubtest(stub="+", runtime="", options=[])
25822582
assert output == (
25832583
"error: not checking stubs due to failed mypy compile:\n{}.pyi:1: "
2584-
"error: Invalid syntax [syntax]\n".format(TEST_MODULE_NAME)
2584+
"error: Invalid syntax [syntax]\n"
2585+
" +\n"
2586+
" ^\n".format(TEST_MODULE_NAME)
25852587
)
25862588

25872589
output = run_stubtest(stub="def f(): ...\ndef f(): ...", runtime="", options=[])
25882590
assert output == (
25892591
"error: not checking stubs due to mypy build errors:\n{}.pyi:2: "
2590-
'error: Name "f" already defined on line 1 [no-redef]\n'.format(TEST_MODULE_NAME)
2592+
'error: Name "f" already defined on line 1 [no-redef]\n'
2593+
" def f(): ...\n"
2594+
" ^~~~~~~~~~~~\n".format(TEST_MODULE_NAME)
25912595
)
25922596

25932597
def test_missing_stubs(self) -> None:
@@ -2665,6 +2669,8 @@ def test_config_file_error_codes(self) -> None:
26652669
assert output == (
26662670
"error: not checking stubs due to mypy build errors:\n"
26672671
'test_module.pyi:1: error: Name "SOME_GLOBAL_CONST" is not defined [name-defined]\n'
2672+
" temp = SOME_GLOBAL_CONST\n"
2673+
" ^~~~~~~~~~~~~~~~~\n"
26682674
)
26692675

26702676
config_file = "[mypy]\ndisable_error_code = name-defined\n"

0 commit comments

Comments
 (0)