MCPcopy
hub / github.com/python/mypy / test_error_stream

Function test_error_stream

mypy/test/testerrorstream.py:22–46  ·  view source on GitHub ↗

Perform a single error streaming test case. The argument contains the description of the test case.

(testcase: DataDrivenTestCase)

Source from the content-addressed store, hash-verified

20
21
22def test_error_stream(testcase: DataDrivenTestCase) -> None:
23 """Perform a single error streaming test case.
24
25 The argument contains the description of the test case.
26 """
27 options = Options()
28 options.show_traceback = True
29 options.hide_error_codes = True
30
31 logged_messages: list[str] = []
32
33 def flush_errors(filename: str | None, msgs: list[str], serious: bool) -> None:
34 if msgs:
35 logged_messages.append("==== Errors flushed ====")
36 logged_messages.extend(msgs)
37
38 sources = [BuildSource("main", "__main__", "\n".join(testcase.input))]
39 try:
40 build.build(sources=sources, options=options, flush_errors=flush_errors)
41 except CompileError as e:
42 assert e.messages == []
43
44 assert_string_arrays_equal(
45 testcase.output, logged_messages, f"Invalid output ({testcase.file}, line {testcase.line})"
46 )

Callers 1

run_caseMethod · 0.85

Calls 5

OptionsClass · 0.90
BuildSourceClass · 0.90
joinMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…