(self)
| 347 | raise |
| 348 | |
| 349 | def setup(self) -> None: |
| 350 | parse_test_case(case=self) |
| 351 | self.old_cwd = os.getcwd() |
| 352 | self.tmpdir = tempfile.mkdtemp(prefix="mypy-test-") |
| 353 | os.chdir(self.tmpdir) |
| 354 | os.mkdir(test_temp_dir) |
| 355 | |
| 356 | # Precalculate steps for find_steps() |
| 357 | steps: dict[int, list[FileOperation]] = {} |
| 358 | |
| 359 | for path, content in self.files: |
| 360 | m = re.match(r".*\.([0-9]+)$", path) |
| 361 | if m: |
| 362 | # Skip writing subsequent incremental steps - rather |
| 363 | # store them as operations. |
| 364 | num = int(m.group(1)) |
| 365 | assert num >= 2 |
| 366 | target_path = re.sub(r"\.[0-9]+$", "", path) |
| 367 | module = module_from_path(target_path) |
| 368 | operation = UpdateFile(module, content, target_path) |
| 369 | steps.setdefault(num, []).append(operation) |
| 370 | else: |
| 371 | # Write the first incremental steps |
| 372 | dir = os.path.dirname(path) |
| 373 | os.makedirs(dir, exist_ok=True) |
| 374 | with open(path, "w", encoding="utf8") as f: |
| 375 | f.write(content) |
| 376 | |
| 377 | for num, paths in self.deleted_paths.items(): |
| 378 | assert num >= 2 |
| 379 | for path in paths: |
| 380 | module = module_from_path(path) |
| 381 | steps.setdefault(num, []).append(DeleteFile(module, path)) |
| 382 | max_step = max(steps) if steps else 2 |
| 383 | self.steps = [steps.get(num, []) for num in range(2, max_step + 1)] |
| 384 | |
| 385 | def teardown(self) -> None: |
| 386 | if self.old_cwd is not None: |
nothing calls this directly
no test coverage detected