Perform a single error streaming test case. The argument contains the description of the test case.
(testcase: DataDrivenTestCase)
| 20 | |
| 21 | |
| 22 | def 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 | ) |
no test coverage detected
searching dependent graphs…