(self, testcase: DataDrivenTestCase, incremental_step: int)
| 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 |
no test coverage detected