| 52 | |
| 53 | |
| 54 | def _flush_coverage() -> None: # pragma: win32 no cover - a spawned child inherits no coverage to flush |
| 55 | # An unmeasured run has nothing to write, and importing coverage there would stop the suite from running at all. |
| 56 | if not CAPABILITIES["coverage"]: # pragma: lacks coverage |
| 57 | return |
| 58 | from coverage import Coverage |
| 59 | |
| 60 | # Reaching the other side needs coverage inactive, which is when nothing gets recorded anyway. |
| 61 | if (coverage := Coverage.current()) is not None: # pragma: no branch |
| 62 | coverage.save() |
| 63 | |
| 64 | |
| 65 | def _restart_coverage_after_fork() -> None: # pragma: win32 no cover |