Perform an identity transform test case.
(testcase: DataDrivenTestCase)
| 30 | |
| 31 | |
| 32 | def test_transform(testcase: DataDrivenTestCase) -> None: |
| 33 | """Perform an identity transform test case.""" |
| 34 | |
| 35 | try: |
| 36 | src = "\n".join(testcase.input) |
| 37 | options = parse_options(src, testcase, 1) |
| 38 | options.use_builtins_fixtures = True |
| 39 | options.semantic_analysis_only = True |
| 40 | options.show_traceback = True |
| 41 | options.reveal_verbose_types = True |
| 42 | result = build.build( |
| 43 | sources=[BuildSource("main", None, src)], options=options, alt_lib_path=test_temp_dir |
| 44 | ) |
| 45 | a = result.errors |
| 46 | if a: |
| 47 | raise CompileError(a) |
| 48 | # Include string representations of the source files in the actual |
| 49 | # output. |
| 50 | for module in sorted(result.files.keys()): |
| 51 | if module in testcase.test_modules: |
| 52 | t = TypeAssertTransformVisitor() |
| 53 | t.test_only = True |
| 54 | file = t.mypyfile(result.files[module]) |
| 55 | a += file.str_with_options(options).split("\n") |
| 56 | except CompileError as e: |
| 57 | a = e.messages |
| 58 | if testcase.normalize_output: |
| 59 | a = normalize_error_messages(a) |
| 60 | assert_string_arrays_equal( |
| 61 | testcase.output, |
| 62 | a, |
| 63 | f"Invalid semantic analyzer output ({testcase.file}, line {testcase.line})", |
| 64 | ) |
no test coverage detected
searching dependent graphs…