MCPcopy Create free account
hub / github.com/python/mypy / run_case

Method run_case

mypy/test/testsemanal.py:127–152  ·  view source on GitHub ↗

Perform a test case.

(self, testcase: DataDrivenTestCase)

Source from the content-addressed store, hash-verified

125 files = ["semanal-symtable.test"]
126
127 def run_case(self, testcase: DataDrivenTestCase) -> None:
128 """Perform a test case."""
129 try:
130 # Build test case input.
131 src = "\n".join(testcase.input)
132 result = build.build(
133 sources=[BuildSource("main", None, src)],
134 options=get_semanal_options(src, testcase),
135 alt_lib_path=test_temp_dir,
136 )
137 # The output is the symbol table converted into a string.
138 a = result.errors
139 if a:
140 raise CompileError(a)
141 for module in sorted(result.files.keys()):
142 if module in testcase.test_modules:
143 a.append(f"{module}:")
144 for s in str(result.files[module].names).split("\n"):
145 a.append(" " + s)
146 except CompileError as e:
147 a = e.messages
148 assert_string_arrays_equal(
149 testcase.output,
150 a,
151 f"Invalid semantic analyzer output ({testcase.file}, line {testcase.line})",
152 )
153
154
155# Type info export test cases

Callers

nothing calls this directly

Calls 11

BuildSourceClass · 0.90
CompileErrorClass · 0.90
get_semanal_optionsFunction · 0.85
sortedFunction · 0.85
strClass · 0.85
keysMethod · 0.80
appendMethod · 0.80
splitMethod · 0.80
joinMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected