MCPcopy
hub / github.com/python/mypy / run_case

Method run_case

mypy/test/testfinegrained.py:75–142  ·  view source on GitHub ↗
(self, testcase: DataDrivenTestCase)

Source from the content-addressed store, hash-verified

73 return False
74
75 def run_case(self, testcase: DataDrivenTestCase) -> None:
76 if self.should_skip(testcase):
77 pytest.skip()
78
79 main_src = "\n".join(testcase.input)
80 main_path = os.path.join(test_temp_dir, "main")
81 with open(main_path, "w", encoding="utf8") as f:
82 f.write(main_src)
83
84 options = self.get_options(main_src, testcase, build_cache=False)
85 if options.python_version > sys.version_info:
86 pytest.skip("Test case requires a newer Python version")
87
88 build_options = self.get_options(main_src, testcase, build_cache=True)
89 server = Server(options, DEFAULT_STATUS_FILE)
90
91 num_regular_incremental_steps = self.get_build_steps(main_src)
92 step = 1
93 sources = self.parse_sources(main_src, step, options)
94 if step <= num_regular_incremental_steps:
95 messages = self.build(build_options, sources)
96 else:
97 messages = self.run_check(server, sources)
98
99 a = []
100 if messages:
101 a.extend(normalize_messages(messages))
102
103 assert testcase.tmpdir is not None
104 a.extend(self.maybe_suggest(step, server, main_src, testcase.tmpdir))
105 a.extend(self.maybe_inspect(step, server, main_src))
106
107 if server.fine_grained_manager:
108 if CHECK_CONSISTENCY:
109 check_consistency(server.fine_grained_manager)
110
111 steps = testcase.find_steps()
112 all_triggered = []
113
114 for operations in steps:
115 step += 1
116 output, triggered = self.perform_step(
117 operations,
118 server,
119 options,
120 build_options,
121 testcase,
122 main_src,
123 step,
124 num_regular_incremental_steps,
125 )
126 a.append("==")
127 a.extend(output)
128 all_triggered.extend(triggered)
129
130 # Normalize paths in test output (for Windows).
131 a = [line.replace("\\", "/") for line in a]
132

Callers

nothing calls this directly

Calls 15

should_skipMethod · 0.95
get_optionsMethod · 0.95
get_build_stepsMethod · 0.95
parse_sourcesMethod · 0.95
buildMethod · 0.95
run_checkMethod · 0.95
maybe_suggestMethod · 0.95
maybe_inspectMethod · 0.95
perform_stepMethod · 0.95
format_triggeredMethod · 0.95
ServerClass · 0.90
check_consistencyFunction · 0.90

Tested by

no test coverage detected