We have a product with multiple python scripts which executes as different processes, sub-processes, daemons and on apache using mod-wsgi. The product runs on top of debian 9 and the scripts are writtent in python2.7. I am trying to use coverage to track code coverage while running automation or integration tests.
I did the following configuration in my sitecustomize.py file to make sure that coverage module is started before running any of our code but I am not able to get proper coverage reports for the same. Please find the sitecustomize.py and coveragerc configuration below.
===========================
.coveragerc
branch=True
concurrency=
multiprocessing
thread
omit =
*tests*
*__init__*
[report]
ignore_errors=False
[html]
directory=/opt/ coverage/coverage_html
Approach 1 : COVERAGE_PROCESS_START from /etc/python2.7/sitecustomize.py
import coverage
import os
os.putenv("COVERAGE_PROCESS_START","/etc/coverage/.coveragerc")
coverage.process_startup()
Approach 2 : coverage.start() from /etc/python2.7/sitecustomize.py
cov = coverage.Coverage(
branch=True,
include=[<List>],
omit=["*/__init__.py"])
cov.start()
def exit_handler():
cov.stop()
cov.save()
cov.report()
cov.html_report(directory="/opt/coverage")
atexit.register(exit_handler)
We are getting the same result/coverage-report each time for no matter what module we are executing. Could you please help us for the same.
One more thing, we get correct coverage report for unittest, executed using command:
coverage run -m <unitTestScripts>
Thanks!!
Aucun commentaire:
Enregistrer un commentaire