MCPcopy Index your code
hub / github.com/python/mypy / run_case_step

Method run_case_step

mypyc/test/test_run.py:214–452  ·  view source on GitHub ↗
(self, testcase: DataDrivenTestCase, incremental_step: int)

Source from the content-addressed store, hash-verified

212 self.run_case_step(testcase, step)
213
214 def run_case_step(self, testcase: DataDrivenTestCase, incremental_step: int) -> None:
215 benchmark_build = has_test_name_tag(testcase.name, "benchmark")
216 bench = testcase.config.getoption("--bench", False) and (
217 benchmark_build or "Benchmark" in testcase.name
218 )
219
220 options = Options()
221 options.use_builtins_fixtures = True
222 options.show_traceback = True
223 options.strict_optional = True
224 options.strict_bytes = True
225 options.disable_bytearray_promotion = True
226 options.disable_memoryview_promotion = True
227 options.python_version = sys.version_info[:2]
228 options.export_types = True
229 options.preserve_asts = True
230 options.allow_empty_bodies = True
231 options.incremental = self.separate
232 options.check_untyped_defs = True
233
234 # Avoid checking modules/packages named 'unchecked', to provide a way
235 # to test interacting with code we don't have types for.
236 options.per_module_options["unchecked.*"] = {"follow_imports": "error"}
237
238 source = build.BuildSource("native.py", "native", None)
239 sources = [source]
240 module_names = ["native"]
241 module_paths = ["native.py"]
242
243 # Hard code another module name to compile in the same compilation unit.
244 to_delete = []
245 for fn, text in testcase.files:
246 fn = os.path.relpath(fn, test_temp_dir)
247
248 if os.path.basename(fn).startswith("other") and fn.endswith(".py"):
249 name = fn.split(".")[0].replace(os.sep, ".")
250 module_names.append(name)
251 sources.append(build.BuildSource(fn, name, None))
252 to_delete.append(fn)
253 module_paths.append(fn)
254
255 shutil.copyfile(fn, os.path.join(os.path.dirname(fn), name + "_interpreted.py"))
256 elif fn.endswith("__init__.py"):
257 pkg_dir = os.path.dirname(fn)
258 if os.path.basename(pkg_dir).startswith("other"):
259 name = pkg_dir.replace(os.sep, ".")
260 module_names.append(name)
261 sources.append(build.BuildSource(fn, name, None))
262 to_delete.append(fn)
263 module_paths.append(fn)
264
265 for source in sources:
266 options.per_module_options.setdefault(source.module, {})["mypyc"] = True
267
268 separate = (
269 self.get_separate("\n".join(testcase.input), incremental_step)
270 if self.separate
271 else False

Callers 1

run_case_innerMethod · 0.95

Calls 15

get_separateMethod · 0.95
flush_errorsMethod · 0.95
has_test_name_tagFunction · 0.90
OptionsClass · 0.90
construct_groupsFunction · 0.90
CompilerOptionsClass · 0.90
ErrorsClass · 0.90
get_librt_pathFunction · 0.90
show_cFunction · 0.90
assert_test_outputFunction · 0.90

Tested by

no test coverage detected