ansible/test/lib/ansible_test/_internal/commands/coverage/erase.py
Matt Clay df2ae06d46 Fix ansible-test imports and paths after refactor.
Also include a changelog entry covering this commit and the previous.
2021-05-05 16:20:15 -07:00

27 lines
646 B
Python

"""Erase code coverage files."""
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
from ...util_common import (
ResultType,
)
from . import (
CoverageConfig,
)
def command_coverage_erase(args): # type: (CoverageConfig) -> None
"""Erase code coverage data files collected during test runs."""
coverage_dir = ResultType.COVERAGE.path
for name in os.listdir(coverage_dir):
if not name.startswith('coverage') and '=coverage.' not in name:
continue
path = os.path.join(coverage_dir, name)
if not args.explain:
os.remove(path)