pytest-abort 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,152 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+
135
+ 6. Trademarks. This License does not grant permission to use the trade
136
+ names, trademarks, service marks, or product names of the Licensor.
137
+
138
+ 7. Disclaimer of Warranty. Unless required by applicable law or
139
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
140
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
141
+
142
+ 8. Limitation of Liability. In no event and under no legal theory,
143
+ whether in tort, contract, or otherwise, shall any Contributor be
144
+ liable for any damages arising as a result of this License or use
145
+ of the Work.
146
+
147
+ 9. Accepting Warranty or Additional Liability. While redistributing
148
+ the Work, You may choose to offer support, warranty, indemnity, or
149
+ other liability obligations and/or rights consistent with this License.
150
+
151
+ END OF TERMS AND CONDITIONS
152
+
@@ -0,0 +1,384 @@
1
+ Metadata-Version: 2.4
2
+ Name: pytest-abort
3
+ Version: 0.1.0
4
+ Summary: Pytest plugin + helpers for attributing hard crashes (SIGSEGV/SIGABRT) to the last running test and keeping pytest-html reports mergeable.
5
+ License: Apache License
6
+ Version 2.0, January 2004
7
+ http://www.apache.org/licenses/
8
+
9
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
10
+
11
+ 1. Definitions.
12
+
13
+ "License" shall mean the terms and conditions for use, reproduction,
14
+ and distribution as defined by Sections 1 through 9 of this document.
15
+
16
+ "Licensor" shall mean the copyright owner or entity authorized by
17
+ the copyright owner that is granting the License.
18
+
19
+ "Legal Entity" shall mean the union of the acting entity and all
20
+ other entities that control, are controlled by, or are under common
21
+ control with that entity. For the purposes of this definition,
22
+ "control" means (i) the power, direct or indirect, to cause the
23
+ direction or management of such entity, whether by contract or
24
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
25
+ outstanding shares, or (iii) beneficial ownership of such entity.
26
+
27
+ "You" (or "Your") shall mean an individual or Legal Entity
28
+ exercising permissions granted by this License.
29
+
30
+ "Source" form shall mean the preferred form for making modifications,
31
+ including but not limited to software source code, documentation
32
+ source, and configuration files.
33
+
34
+ "Object" form shall mean any form resulting from mechanical
35
+ transformation or translation of a Source form, including but
36
+ not limited to compiled object code, generated documentation,
37
+ and conversions to other media types.
38
+
39
+ "Work" shall mean the work of authorship, whether in Source or
40
+ Object form, made available under the License, as indicated by a
41
+ copyright notice that is included in or attached to the work
42
+ (an example is provided in the Appendix below).
43
+
44
+ "Derivative Works" shall mean any work, whether in Source or Object
45
+ form, that is based on (or derived from) the Work and for which the
46
+ editorial revisions, annotations, elaborations, or other modifications
47
+ represent, as a whole, an original work of authorship. For the purposes
48
+ of this License, Derivative Works shall not include works that remain
49
+ separable from, or merely link (or bind by name) to the interfaces of,
50
+ the Work and Derivative Works thereof.
51
+
52
+ "Contribution" shall mean any work of authorship, including
53
+ the original version of the Work and any modifications or additions
54
+ to that Work or Derivative Works thereof, that is intentionally
55
+ submitted to Licensor for inclusion in the Work by the copyright owner
56
+ or by an individual or Legal Entity authorized to submit on behalf of
57
+ the copyright owner. For the purposes of this definition, "submitted"
58
+ means any form of electronic, verbal, or written communication sent
59
+ to the Licensor or its representatives, including but not limited to
60
+ communication on electronic mailing lists, source code control systems,
61
+ and issue tracking systems that are managed by, or on behalf of, the
62
+ Licensor for the purpose of discussing and improving the Work, but
63
+ excluding communication that is conspicuously marked or otherwise
64
+ designated in writing by the copyright owner as "Not a Contribution."
65
+
66
+ "Contributor" shall mean Licensor and any individual or Legal Entity
67
+ on behalf of whom a Contribution has been received by Licensor and
68
+ subsequently incorporated within the Work.
69
+
70
+ 2. Grant of Copyright License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ copyright license to reproduce, prepare Derivative Works of,
74
+ publicly display, publicly perform, sublicense, and distribute the
75
+ Work and such Derivative Works in Source or Object form.
76
+
77
+ 3. Grant of Patent License. Subject to the terms and conditions of
78
+ this License, each Contributor hereby grants to You a perpetual,
79
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
80
+ (except as stated in this section) patent license to make, have made,
81
+ use, offer to sell, sell, import, and otherwise transfer the Work,
82
+ where such license applies only to those patent claims licensable
83
+ by such Contributor that are necessarily infringed by their
84
+ Contribution(s) alone or by combination of their Contribution(s)
85
+ with the Work to which such Contribution(s) was submitted. If You
86
+ institute patent litigation against any entity (including a
87
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
88
+ or a Contribution incorporated within the Work constitutes direct
89
+ or contributory patent infringement, then any patent licenses
90
+ granted to You under this License for that Work shall terminate
91
+ as of the date such litigation is filed.
92
+
93
+ 4. Redistribution. You may reproduce and distribute copies of the
94
+ Work or Derivative Works thereof in any medium, with or without
95
+ modifications, and in Source or Object form, provided that You
96
+ meet the following conditions:
97
+
98
+ (a) You must give any other recipients of the Work or
99
+ Derivative Works a copy of this License; and
100
+
101
+ (b) You must cause any modified files to carry prominent notices
102
+ stating that You changed the files; and
103
+
104
+ (c) You must retain, in the Source form of any Derivative Works
105
+ that You distribute, all copyright, patent, trademark, and
106
+ attribution notices from the Source form of the Work,
107
+ excluding those notices that do not pertain to any part of
108
+ the Derivative Works; and
109
+
110
+ (d) If the Work includes a "NOTICE" text file as part of its
111
+ distribution, then any Derivative Works that You distribute must
112
+ include a readable copy of the attribution notices contained
113
+ within such NOTICE file, excluding those notices that do not
114
+ pertain to any part of the Derivative Works, in at least one
115
+ of the following places: within a NOTICE text file distributed
116
+ as part of the Derivative Works; within the Source form or
117
+ documentation, if provided along with the Derivative Works; or,
118
+ within a display generated by the Derivative Works, if and
119
+ wherever such third-party notices normally appear. The contents
120
+ of the NOTICE file are for informational purposes only and
121
+ do not modify the License. You may add Your own attribution
122
+ notices within Derivative Works that You distribute, alongside
123
+ or as an addendum to the NOTICE text from the Work, provided
124
+ that such additional attribution notices cannot be construed
125
+ as modifying the License.
126
+
127
+ You may add Your own copyright statement to Your modifications and
128
+ may provide additional or different license terms and conditions
129
+ for use, reproduction, or distribution of Your modifications, or
130
+ for any such Derivative Works as a whole, provided Your use,
131
+ reproduction, and distribution of the Work otherwise complies with
132
+ the conditions stated in this License.
133
+
134
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
135
+ any Contribution intentionally submitted for inclusion in the Work
136
+ by You to the Licensor shall be under the terms and conditions of
137
+ this License, without any additional terms or conditions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor.
141
+
142
+ 7. Disclaimer of Warranty. Unless required by applicable law or
143
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
144
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
145
+
146
+ 8. Limitation of Liability. In no event and under no legal theory,
147
+ whether in tort, contract, or otherwise, shall any Contributor be
148
+ liable for any damages arising as a result of this License or use
149
+ of the Work.
150
+
151
+ 9. Accepting Warranty or Additional Liability. While redistributing
152
+ the Work, You may choose to offer support, warranty, indemnity, or
153
+ other liability obligations and/or rights consistent with this License.
154
+
155
+ END OF TERMS AND CONDITIONS
156
+
157
+
158
+ Keywords: pytest,plugin,crash,segfault,sigabrt,reporting
159
+ Classifier: Development Status :: 3 - Alpha
160
+ Classifier: Framework :: Pytest
161
+ Classifier: Intended Audience :: Developers
162
+ Classifier: License :: OSI Approved :: Apache Software License
163
+ Classifier: Programming Language :: Python :: 3
164
+ Classifier: Programming Language :: Python :: 3 :: Only
165
+ Classifier: Topic :: Software Development :: Testing
166
+ Requires-Python: >=3.8
167
+ Description-Content-Type: text/markdown
168
+ License-File: LICENSE
169
+ Requires-Dist: pytest>=7.0
170
+ Dynamic: license-file
171
+
172
+ # pytest-abort
173
+
174
+ `pytest-abort` is a pytest plugin + helper library to **attribute hard crashes (SIGSEGV/SIGABRT) to the last running test** and to keep pytest-html reports **mergeable and renderable** by sanitizing `data-jsonblob` payloads before `pytest_html_merger` runs.
175
+
176
+ ## What this repo contains
177
+
178
+ - **Pytest plugin**: `pytest_abort.plugin`
179
+ - Writes a JSON “last-running test” marker file before each test starts.
180
+ - Deletes the marker file on normal test completion.
181
+ - If pytest hard-crashes, cleanup never runs and the marker file remains with `status="running"`.
182
+
183
+ - **Crash marker parser**: `pytest_abort.crash_file`
184
+ - `check_for_crash_file(path) -> dict | None`
185
+
186
+ - **Runner helpers (library module)**: `pytest_abort.abort_handling`
187
+ - `handle_abort(json_file, html_file, last_running_file, testfile, crash_info=None) -> bool`
188
+ - `append_abort_to_json(...)`, `append_abort_to_html(...)`
189
+ - `sanitize_html_file_jsonblob(path)`, `sanitize_all_html_jsonblobs(log_dir)`
190
+
191
+ ## Key concept: the last-running marker file
192
+
193
+ The plugin writes a small JSON file (path supplied by the runner) like:
194
+
195
+ ```json
196
+ {
197
+ "test_name": "test_foo",
198
+ "nodeid": "tests/test_bar.py::TestBar::test_foo",
199
+ "start_time": "2026-01-14T23:59:59.123456",
200
+ "status": "running",
201
+ "pid": 12345,
202
+ "gpu_id": "0"
203
+ }
204
+ ```
205
+
206
+ If pytest exits normally, the file is deleted. If pytest is killed by a segfault/abort, the file remains and the outer runner can attribute the crash.
207
+
208
+ ## Installation
209
+
210
+ Editable install:
211
+
212
+ ```bash
213
+ python3 -m pip install -e .
214
+ ```
215
+
216
+ If you plan to use `-n` (parallel execution) and/or per-test timeouts, you likely also want:
217
+
218
+ ```bash
219
+ python3 -m pip install -U pytest-xdist pytest-timeout
220
+ ```
221
+
222
+ ## Build a wheel
223
+
224
+ Build the wheel from the repo root:
225
+
226
+ ```bash
227
+ python3 -m pip install --upgrade build
228
+ python3 -m build
229
+ ```
230
+
231
+ The wheel is produced under:
232
+
233
+ - `./dist/` (for example: `./dist/pytest_abort-0.1.0-py3-none-any.whl`)
234
+
235
+ Install the wheel:
236
+
237
+ ```bash
238
+ python3 -m pip install ./dist/*.whl
239
+ ```
240
+
241
+ ## Using the plugin directly (debugging)
242
+
243
+ Recommended (env var):
244
+
245
+ ```bash
246
+ PYTEST_ABORT_LAST_RUNNING_FILE=/tmp/last_running.json \
247
+ python3 -m pytest -q tests/test_something.py
248
+ ```
249
+
250
+ Note:
251
+ - If `pytest-abort` is **installed** (editable or wheel), pytest auto-loads it via the `pytest11` entry point, so you **do not** need `-p ...`.
252
+ - If the plugin is **installed** and you want to load it explicitly anyway, use `-p pytest_abort`.
253
+ - If the plugin is **not installed** and you’re loading it via `PYTHONPATH` only, use `-p pytest_abort.plugin`.
254
+ - Don’t use `-p ...` when it’s already auto-loaded, or pytest will error with “Plugin already registered”.
255
+
256
+ Optional CLI override:
257
+
258
+ ```bash
259
+ python3 -m pytest \
260
+ --last-running-file /tmp/last_running.json \
261
+ -q tests/test_something.py
262
+ ```
263
+
264
+ ## Crashed-tests log (optional)
265
+
266
+ You can also write a shared **crashed tests log** (JSONL: one JSON object per line).
267
+
268
+ - Set `PYTEST_ABORT_CRASHED_TESTS_LOG=/path/to/crashed_tests.jsonl`
269
+ - For `pytest -n` (xdist), also set `PYTEST_ABORT_LAST_RUNNING_DIR=/path/to/dir` (so each worker writes its own marker file).
270
+
271
+ Example:
272
+
273
+ ```bash
274
+ export PYTEST_ABORT_LAST_RUNNING_DIR=/tmp/last_running
275
+ export PYTEST_ABORT_CRASHED_TESTS_LOG=/tmp/crashed_tests.jsonl
276
+
277
+ pytest -n 8 tests
278
+ ```
279
+
280
+ Notes:
281
+ - In xdist, the **master process** appends to the crashed-tests log when a worker goes down.
282
+ - In runner flows (like `run_single_gpu.py`), `handle_abort(...)` appends to the crashed-tests log if `PYTEST_ABORT_CRASHED_TESTS_LOG` is set.
283
+
284
+ ## Crash recovery for xdist runs (optional helper)
285
+
286
+ If you want a “crash recovery” loop for `pytest -n ...`, you can use the included outer-process wrapper:
287
+
288
+ ```bash
289
+ pytest-abort-retry --max-runs 5 --clear-crash-log -- \
290
+ pytest -n 8 --max-worker-restart=50 --tb=short --maxfail=20 tests examples
291
+ ```
292
+
293
+ Per-test timeout example (requires `pytest-timeout`):
294
+
295
+ ```bash
296
+ pytest-abort-retry --max-runs 5 --clear-crash-log -- \
297
+ pytest -n 8 --max-worker-restart=50 --tb=short --maxfail=20 \
298
+ --timeout=600 --timeout-method=thread \
299
+ tests examples
300
+ ```
301
+
302
+ This will:
303
+ - run pytest
304
+ - read `PYTEST_ABORT_CRASHED_TESTS_LOG`
305
+ - re-run pytest with `--deselect=<nodeid>` for crashed nodeids until stable (or `--max-runs`).
306
+
307
+ Note:
308
+ - The wrapper supports the standard `... -- pytest ...` form.
309
+ - To avoid “wrong pytest binary / wrong environment” problems (missing `-n`, missing `--timeout`, etc.), the wrapper rewrites a leading `pytest ...` to run as `python -m pytest ...` using the wrapper’s interpreter.
310
+
311
+
312
+ ## Integration notes (outer runner)
313
+
314
+ If you run pytest from an outer process (CI wrapper, custom runner, etc.), a common pattern is:
315
+
316
+ - Add this package to the environment (editable install or wheel)
317
+ - Set `PYTEST_ABORT_LAST_RUNNING_FILE` (or `PYTEST_ABORT_LAST_RUNNING_DIR` for xdist)
318
+ - Produce per-run JSON/HTML artifacts with `pytest-json-report` and `pytest-html` (best-effort)
319
+ - If a hard crash occurred, patch/repair the per-run artifacts from the outer process via `handle_abort(...)`
320
+ - Before merging many HTML reports, sanitize `data-jsonblob` payloads so merge/HTML rendering stays robust
321
+
322
+ ## How rocm-jax uses it
323
+
324
+ The [`rocm-jax`](https://github.com/ROCm/rocm-jax) test runners use `pytest-abort` to attribute hard crashes to the last-running test and to keep pytest-html reports mergeable.
325
+
326
+ ### `run_single_gpu.py`
327
+
328
+ - Ensures `pytest_abort` is importable by the pytest subprocess (either by installing `pytest-abort` into the environment, or by adding the repo checkout to `PYTHONPATH`)
329
+ - Enables the plugin via the installed `pytest11` entry point (no `-p` needed when installed). If using `PYTHONPATH` only, load explicitly with `-p pytest_abort.plugin`.
330
+ - Sets `PYTEST_ABORT_LAST_RUNNING_FILE` per test-file run (`logs/*_last_running.json`)
331
+ - On crash: re-runs remaining tests in the same file using `--deselect <crashed-nodeid>`
332
+ - Appends crash info into `*_log.json` + `*_log.html` using `pytest_abort.abort_handling.handle_abort(...)`
333
+ - Sanitizes per-file HTML jsonblobs before merging:
334
+ - `sanitize_all_html_jsonblobs("./logs")` then `pytest_html_merger`
335
+
336
+ ### `run_multi_gpu.py`
337
+
338
+ - Uses the same plugin and env-var mechanism for its pytest subprocesses
339
+ - Uses the same `./logs` directory and does **not** archive logs
340
+
341
+ ## Using the helper library from a runner (example)
342
+
343
+ Hard crashes can prevent `pytest-html` / `pytest-json-report` from finishing their output files. The pattern used by the ROCm runners is:
344
+
345
+ - Run pytest with `--html=...` and `--json-report-file=...` (best-effort)
346
+ - Detect a hard crash via the last-running marker file
347
+ - Call `pytest_abort.abort_handling.handle_abort(...)` **from the runner process** to ensure the per-testfile `*_log.json` and `*_log.html` exist and contain a synthetic “crashed” test entry
348
+
349
+ Minimal example:
350
+
351
+ ```python
352
+ import os
353
+ import subprocess
354
+
355
+ from pytest_abort.abort_handling import handle_abort, sanitize_all_html_jsonblobs
356
+
357
+ json_log = "logs/example_log.json"
358
+ html_log = "logs/example_log.html"
359
+ last_running = "logs/example_last_running.json"
360
+
361
+ env = os.environ.copy()
362
+ env["PYTEST_ABORT_LAST_RUNNING_FILE"] = os.path.abspath(last_running)
363
+
364
+ subprocess.run(
365
+ [
366
+ "python3",
367
+ "-m",
368
+ "pytest",
369
+ # Plugin is auto-loaded via pytest11 entry point when installed.
370
+ "--json-report",
371
+ f"--json-report-file={json_log}",
372
+ f"--html={html_log}",
373
+ "tests/some_test_file.py",
374
+ ],
375
+ env=env,
376
+ check=False,
377
+ )
378
+
379
+ # If a crash happened, this ensures JSON/HTML logs exist and are patched:
380
+ handle_abort(json_log, html_log, last_running, testfile="some_test_file")
381
+
382
+ # Before merging many per-file HTML reports:
383
+ sanitize_all_html_jsonblobs("logs")
384
+ ```