1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-09-15 20:36:55 +00:00

Measure coverage of forked processes

This commit is contained in:
Unrud 2018-09-09 07:28:36 +02:00
parent ae99584a7b
commit e4ee569bd2
2 changed files with 37 additions and 15 deletions

View file

@ -26,6 +26,28 @@ import radicale
import sys
from io import BytesIO
from pytest_cov import embed
from radicale import server
# Measure coverage of forked processes
finish_request = server.ParallelHTTPServer.finish_request
pid = os.getpid()
def finish_request_cov(self, request, client_address):
cov = None
if pid != os.getpid():
cov = embed.init()
try:
return finish_request(self, request, client_address)
finally:
if cov:
embed.cleanup(cov)
server.ParallelHTTPServer.finish_request = finish_request_cov
# Allow importing of tests.custom....
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
# Enable debug output