Skip to content

Commit

Permalink
Patch py.process.ForkedFunc to clean up coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
schlamar committed Jun 5, 2014
1 parent 1fe3c48 commit fb100db
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pytest_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@
import pytest

import cov_core
import cov_core_init

from py._process import forkedfunc


class PatchedForkedFunc(forkedfunc.ForkedFunc):

def _child(self, nice_level):
import os
_exit = os._exit
exit_args = list()

def _capture_args(*args):
exit_args.extend(list(args))

os._exit = _capture_args

cov = cov_core_init.init()
try:
super(PatchedForkedFunc, self)._child(nice_level)
finally:
cov_core.multiprocessing_finish(cov)
_exit(*exit_args)

forkedfunc.ForkedFunc = PatchedForkedFunc

from py import process
process.ForkedFunc = PatchedForkedFunc


def pytest_addoption(parser):
Expand Down

0 comments on commit fb100db

Please sign in to comment.