にトップレベルのパッケージ名をオンPythonのカバレッジは、私はこのようにレイアウトされたプロジェクトを持っている期間
pytest -s --junitxml=pytests.xml --cov-report xml --cov-report term-missing --cov-branch --cov=ex_secure
で次にトップレベルのパッケージその結果coverage.xml
を.
命名されています
<package branch-rate="0.4722" complexity="0" line-rate="0.6801" name=".">
しかし、私はを呼び出す場合このような:次に、トップレベルのパッケージが正しくex_secure
という
pytest -s --junitxml=pytests.xml --cov-report xml --cov-report term-missing --cov-branch --cov=ex_secure.base --cov=ex_secure.metrics --cov=ex_secure.keys
:
<package branch-rate="0.4722" complexity="0" line-rate="0.6801" name="ex_secure">
それは今のところ大丈夫な回避策だが、それは理想的ではありません。より多くのパッケージを追加する場合は、それらを列挙しておく必要があります(または、カバレッジレポートに表示されません)。さらに、__init__.py
はこのメカニズムではカバーされません。
私はここで間違っていますか?
UPDATE 1:
私が代わりにpytest-cov
を使用しての直接Pythonのカバレッジを実行した場合、予想通り、それは動作します:
coverage run --branch --source=ex_secure -m pytest -s --junitxml=pytests.xml
coverage xml
その後:
<package branch-rate="0.4722" complexity="0" line-rate="0.6771" name="ex_secure">
UPDATE 2:
私はもともと行ったようPyTestを実行しますが、その後の再生成されたレポートを修正します、直接Pythonのカバレッジを持つXMLレポートを再生成する場合は、しかし、持っているわずかに異なる番号:その後
:
<package branch-rate="0.3058" complexity="0" line-rate="0.4769" name="ex_secure">