MCPcopy
hub / github.com/pytest-dev/pytest / runpytest_inprocess

Method runpytest_inprocess

src/_pytest/pytester.py:1167–1209  ·  view source on GitHub ↗

Return result of running pytest in-process, providing a similar interface to what self.runpytest() provides.

(
        self, *args: str | os.PathLike[str], **kwargs: Any
    )

Source from the content-addressed store, hash-verified

1165 finalizer()
1166
1167 def runpytest_inprocess(
1168 self, *args: str | os.PathLike[str], **kwargs: Any
1169 ) -> RunResult:
1170 """Return result of running pytest in-process, providing a similar
1171 interface to what self.runpytest() provides."""
1172 syspathinsert = kwargs.pop("syspathinsert", False)
1173
1174 if syspathinsert:
1175 self.syspathinsert()
1176 instant = timing.Instant()
1177 capture = _get_multicapture("sys")
1178 capture.start_capturing()
1179 try:
1180 try:
1181 reprec = self.inline_run(*args, **kwargs)
1182 except SystemExit as e:
1183 ret = e.args[0]
1184 try:
1185 ret = ExitCode(e.args[0])
1186 except ValueError:
1187 pass
1188
1189 class reprec: # type: ignore
1190 ret = ret
1191
1192 except Exception:
1193 traceback.print_exc()
1194
1195 class reprec: # type: ignore
1196 ret = ExitCode(3)
1197
1198 finally:
1199 out, err = capture.readouterr()
1200 capture.stop_capturing()
1201 sys.stdout.write(out)
1202 sys.stderr.write(err)
1203
1204 assert reprec.ret is not None
1205 res = RunResult(
1206 reprec.ret, out.splitlines(), err.splitlines(), instant.elapsed().seconds
1207 )
1208 res.reprec = reprec # type: ignore
1209 return res
1210
1211 def runpytest(self, *args: str | os.PathLike[str], **kwargs: Any) -> RunResult:
1212 """Run pytest inline or in a subprocess, depending on the command line

Callers 15

runpytestMethod · 0.95
test_callsMethod · 0.45
test_calls_show_2Method · 0.45
test_calls_showallMethod · 0.45
test_with_deselectedMethod · 0.45
test_with_notMethod · 0.45
test_setup_functionMethod · 0.45

Calls 11

syspathinsertMethod · 0.95
inline_runMethod · 0.95
elapsedMethod · 0.95
_get_multicaptureFunction · 0.90
ExitCodeClass · 0.90
RunResultClass · 0.85
popMethod · 0.80
start_capturingMethod · 0.80
stop_capturingMethod · 0.80
readouterrMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected