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

Function test_parse_error

mypy/test/testparse.py:96–126  ·  view source on GitHub ↗
(testcase: DataDrivenTestCase)

Source from the content-addressed store, hash-verified

94
95
96def 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 )

Callers 1

run_caseMethod · 0.85

Calls 8

is_errorsMethod · 0.95
raise_errorMethod · 0.95
parse_optionsFunction · 0.90
ErrorsClass · 0.90
parseFunction · 0.90
bytesClass · 0.85
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…