Create JSON file.
(self, stack: contextlib.ExitStack)
| 245 | return stdout_file |
| 246 | |
| 247 | def create_json_file(self, stack: contextlib.ExitStack) -> tuple[JsonFile, TextIO | None]: |
| 248 | """Create JSON file.""" |
| 249 | |
| 250 | json_file_use_stdout = self.runtests.json_file_use_stdout() |
| 251 | if json_file_use_stdout: |
| 252 | json_file = JsonFile(None, JsonFileType.STDOUT) |
| 253 | json_tmpfile = None |
| 254 | else: |
| 255 | json_tmpfile = tempfile.TemporaryFile('w+', encoding='utf8') |
| 256 | stack.enter_context(json_tmpfile) |
| 257 | |
| 258 | json_fd = json_tmpfile.fileno() |
| 259 | if MS_WINDOWS: |
| 260 | # The msvcrt module is only available on Windows; |
| 261 | # we run mypy with `--platform=linux` in CI |
| 262 | json_handle: int = msvcrt.get_osfhandle(json_fd) # type: ignore[attr-defined] |
| 263 | json_file = JsonFile(json_handle, |
| 264 | JsonFileType.WINDOWS_HANDLE) |
| 265 | else: |
| 266 | json_file = JsonFile(json_fd, JsonFileType.UNIX_FD) |
| 267 | return (json_file, json_tmpfile) |
| 268 | |
| 269 | def create_worker_runtests(self, test_name: TestName, json_file: JsonFile) -> WorkerRunTests: |
| 270 | tests = (test_name,) |
no test coverage detected