opencadc / caom2tools

Common Archive Observation Model - data engineering tools
2 stars 13 forks source link

Support coverage arguments with the python setup.py coverage command. #83

Open SharonGoliath opened 6 years ago

SharonGoliath commented 6 years ago

As opposed to:

pytest caom2utils --cov --cov-report html
yeunga commented 6 years ago

python setup.py pytest --addopts '--cov --cov-report html'

works and generates coverage reports in html format. Similarly we can replace 'html' with 'xml' for xml formatted coverage reports. Modification to setup.py is not required, so we shall have a cleaner setup.py file by removing the coverage related statements.

We can also define an environment variable, e.g.

export PYTEST_ADDOPTS="--cov --cov-report.xml" python setup.py pytest

However we need to find a place to define the environment variable.

yeunga commented 6 years ago

Updated setup.py based on Adrian's solution. The following commands works:

no coverage report to generate

python setup.py test python setup.py intTest python setup.py allTest

generates a coverage report

python setup.py test --cov --cov-report <type, e.g. html> python setup.py intTest --cov --cov-report <type, e.g. xml> python setup.py allTest --cov --cov-report <type, e.g. term>