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
)
| 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 |
no test coverage detected