(self, testcase: DataDrivenTestCase)
| 58 | files = typecheck_files |
| 59 | |
| 60 | def run_case(self, testcase: DataDrivenTestCase) -> None: |
| 61 | if os.path.basename(testcase.file) == "check-modules-case.test": |
| 62 | with tempfile.NamedTemporaryFile(prefix="test", dir=".") as temp_file: |
| 63 | temp_path = Path(temp_file.name) |
| 64 | if not temp_path.with_name(temp_path.name.upper()).exists(): |
| 65 | pytest.skip("File system is not case-insensitive") |
| 66 | if lxml is None and os.path.basename(testcase.file) == "check-reports.test": |
| 67 | pytest.skip("Cannot import lxml. Is it installed?") |
| 68 | incremental = ( |
| 69 | "incremental" in testcase.name.lower() |
| 70 | or "incremental" in testcase.file |
| 71 | or "serialize" in testcase.file |
| 72 | ) |
| 73 | if incremental: |
| 74 | # Incremental tests are run once with a cold cache, once with a warm cache. |
| 75 | # Expect success on first run, errors from testcase.output (if any) on second run. |
| 76 | num_steps = max([2] + list(testcase.output2.keys())) |
| 77 | # Check that there are no file changes beyond the last run (they would be ignored). |
| 78 | for dn, dirs, files in os.walk(os.curdir): |
| 79 | for file in files: |
| 80 | m = re.search(r"\.([2-9])$", file) |
| 81 | if m and int(m.group(1)) > num_steps: |
| 82 | raise ValueError( |
| 83 | "Output file {} exists though test case only has {} runs".format( |
| 84 | file, num_steps |
| 85 | ) |
| 86 | ) |
| 87 | steps = testcase.find_steps() |
| 88 | for step in range(1, num_steps + 1): |
| 89 | idx = step - 2 |
| 90 | ops = steps[idx] if idx < len(steps) and idx >= 0 else [] |
| 91 | self.run_case_once(testcase, ops, step, True) |
| 92 | else: |
| 93 | self.run_case_once(testcase) |
| 94 | |
| 95 | def _sort_output_if_needed(self, testcase: DataDrivenTestCase, a: list[str]) -> None: |
| 96 | idx = testcase.output_inline_start |
nothing calls this directly
no test coverage detected