revert coverage cmd order

add Process subclass to handle Process in coverage context (unittest)
This commit is contained in:
cclecle
2023-11-06 11:58:48 +00:00
parent 8868f77ef3
commit b91708491a
3 changed files with 26 additions and 1 deletions

View File

@@ -35,3 +35,5 @@ try: # pragma: no cover
except PackageNotFoundError: # pragma: no cover
warnings.warn('can not read dist.metadata["Name"], assuming local test context, setting it to <chacha_cicd_helper>')
__Name__ = "chacha_cicd_helper"
from .coverage_tools import CoverageProcess

View File

@@ -0,0 +1,23 @@
from coverage import Coverage
from multiprocessing import Process
import os
class CoverageProcess(Process):
def __init__(self, *args, config_file=None, **kwargs):
self._config_file = config_file
super().__init__(*args, **kwargs)
def run(self):
if self._config_file:
cov = Coverage(config_file=self._config_file, data_suffix=os.getpid(), auto_data=True)
cov._warn_no_data = False
cov.start()
try:
super().run()
finally:
cov.stop()
cov.save()
else:
super().run()

View File

@@ -64,8 +64,8 @@ class cl_unit_test(cl_helper_withresults_base):
print("Test Finished")
if cls.enable_coverage_check is True:
cov.stop()
cov.combine()
cov.save()
cov.combine()
cov.html_report(directory=str(CoverageReportPath))
cov.xml_report(outfile=str(CoverageReportPath / f"{cls.CoverageReportName}.xml"))