(testcase: DataDrivenTestCase)
| 94 | |
| 95 | |
| 96 | def test_parse_error(testcase: DataDrivenTestCase) -> None: |
| 97 | try: |
| 98 | options = parse_options("\n".join(testcase.input), testcase, 0) |
| 99 | if options.python_version < defaults.PYTHON3_VERSION: |
| 100 | options.python_version = defaults.PYTHON3_VERSION |
| 101 | if options.python_version != sys.version_info[:2]: |
| 102 | skip() |
| 103 | # Compile temporary file. The test file contains non-ASCII characters. |
| 104 | errors = Errors(options) |
| 105 | parse( |
| 106 | bytes("\n".join(testcase.input), "utf-8"), |
| 107 | INPUT_FILE_NAME, |
| 108 | "__main__", |
| 109 | errors=errors, |
| 110 | options=options, |
| 111 | file_exists=False, |
| 112 | eager=True, |
| 113 | ) |
| 114 | if errors.is_errors(): |
| 115 | errors.raise_error() |
| 116 | raise AssertionError("No errors reported") |
| 117 | except CompileError as e: |
| 118 | if e.module_with_blocker is not None: |
| 119 | assert e.module_with_blocker == "__main__" |
| 120 | # Verify that there was a compile error and that the error messages |
| 121 | # are equivalent. |
| 122 | assert_string_arrays_equal( |
| 123 | testcase.output, |
| 124 | e.messages, |
| 125 | f"Invalid compiler output ({testcase.file}, line {testcase.line})", |
| 126 | ) |
no test coverage detected
searching dependent graphs…