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