MCPcopy Create free account
hub / github.com/pytest-dev/pytest / runpytest_inprocess

Method runpytest_inprocess

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

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

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

Source from the content-addressed store, hash-verified

1123 finalizer()
1124
1125 def runpytest_inprocess(
1126 self, *args: Union[str, "os.PathLike[str]"], **kwargs: Any
1127 ) -> RunResult:
1128 """Return result of running pytest in-process, providing a similar
1129 interface to what self.runpytest() provides."""
1130 syspathinsert = kwargs.pop("syspathinsert", False)
1131
1132 if syspathinsert:
1133 self.syspathinsert()
1134 now = timing.time()
1135 capture = _get_multicapture("sys")
1136 capture.start_capturing()
1137 try:
1138 try:
1139 reprec = self.inline_run(*args, **kwargs)
1140 except SystemExit as e:
1141 ret = e.args[0]
1142 try:
1143 ret = ExitCode(e.args[0])
1144 except ValueError:
1145 pass
1146
1147 class reprec: # type: ignore
1148 ret = ret
1149
1150 except Exception:
1151 traceback.print_exc()
1152
1153 class reprec: # type: ignore
1154 ret = ExitCode(3)
1155
1156 finally:
1157 out, err = capture.readouterr()
1158 capture.stop_capturing()
1159 sys.stdout.write(out)
1160 sys.stderr.write(err)
1161
1162 assert reprec.ret is not None
1163 res = RunResult(
1164 reprec.ret, out.splitlines(), err.splitlines(), timing.time() - now
1165 )
1166 res.reprec = reprec # type: ignore
1167 return res
1168
1169 def runpytest(
1170 self, *args: Union[str, "os.PathLike[str]"], **kwargs: Any

Callers 15

runpytestMethod · 0.95
test_clean_upFunction · 0.45
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
_get_multicaptureFunction · 0.90
ExitCodeClass · 0.90
RunResultClass · 0.85
popMethod · 0.80
timeMethod · 0.80
start_capturingMethod · 0.80
stop_capturingMethod · 0.80
readouterrMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected