Skip to content

Commit d9c1163

Browse files
committed
delete old coverage files each test run
1 parent 13175f3 commit d9c1163

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ run = [
8888
"pytest{env:HATCH_TEST_ARGS:} {args}",
8989
]
9090
run-cov = [
91+
'hatch --env default run "src/build_scripts/delete_old_coverage.py"',
9192
'hatch --env default run "src/build_scripts/install_playwright.py"',
9293
"hatch --env default build -t wheel",
9394
"coverage run -m pytest{env:HATCH_TEST_ARGS:} {args}",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# /// script
2+
# requires-python = ">=3.11"
3+
# dependencies = []
4+
# ///
5+
6+
import logging
7+
from glob import glob
8+
from pathlib import Path
9+
10+
# Delete old `.coverage*` files in the project root
11+
print("Deleting old coverage files...") # noqa: T201
12+
root_dir = Path(__file__).parent.parent.parent
13+
coverage_files = glob(str(root_dir / ".coverage*"))
14+
15+
for path in coverage_files:
16+
coverage_file = Path(path)
17+
if coverage_file.exists():
18+
try:
19+
coverage_file.unlink()
20+
except Exception as e:
21+
logging.error(f"Failed to delete {coverage_file}: {e}")

0 commit comments

Comments
 (0)