11

nosetestcoverage.pyプラグインを使用しています。カバレッジレポートからファイルまたはフォルダ全体を除外することはどういうわけか可能ですか?私のユースケースは、明らかに私のテストスイートでカバーされていない外部ライブラリをプロジェクトフォルダに持っていることです。

4

3 に答える 3

4

コード ブロックを除外する場合は、# pragma: no coverコメントを使用します。

いくつかの例:

def foo(self, param): # pragma: no cover <--
    """ Exclude an entire function """
    # None of this will be included in coverage

def bar(self, param):
    """ Exclude a branch of code """
    if param:
        # This part is included in code coverage
        do_this()
    else: # pragma: no cover <--
        # Not included in coverage
        other_thing()

詳しくはドキュメントをご覧ください。

于 2021-04-07T14:37:39.307 に答える