File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -221,14 +221,22 @@ def foo() -> None:
221221 # if this test fails, this will hang, triggering a timeout.
222222 os .waitpid (child_pid , 0 )
223223 else :
224+ # this is necessary because os._exit doesn't unwind the stack,
225+ # so coverage doesn't get to automatically stop and save
226+ # coverage information.
224227 try :
225228 import coverage
226229
227230 cov = coverage .Coverage .current ()
231+ # the following pragmas are necessary because if coverage:
232+ # - isn't running, then it can't record the branch not
233+ # taken
234+ # - isn't installed, then it can't record the ImportError
235+
228236 if cov : # pragma: no branch
229237 cov .stop ()
230238 cov .save ()
231239 except ImportError : # pragma: no cover
232240 pass
233241
234- os ._exit (0 ) # pragma: no cover
242+ os ._exit (0 ) # pragma: no cover # coverage was stopped above.
You can’t perform that action at this time.
0 commit comments