Skip to content

Commit 1fcdd0e

Browse files
committed
tests: use coverage instead of pytest-cov
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent d808330 commit 1fcdd0e

2 files changed

Lines changed: 25 additions & 21 deletions

File tree

noxfile.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121

2222
from __future__ import annotations
2323

24-
import contextlib
2524
import functools
2625
import os
2726
import shutil
28-
import sqlite3
2927
import sys
3028

3129
import nox
@@ -44,30 +42,33 @@ def tests(session: nox.Session) -> None:
4442
"""Run test suite with pytest."""
4543

4644
coverage_file = f".coverage.pypi.{sys.platform}.{session.python}"
45+
env = {
46+
"PYTHONWARNDEFAULTENCODING": "1",
47+
"COVERAGE_FILE": coverage_file,
48+
}
4749

4850
session.create_tmp() # Fixes permission errors on Windows
4951
session.install(*PYPROJECT["dependency-groups"]["test"], "uv")
5052
session.install("-e.[tox_to_nox,pbs]")
53+
session.run("coverage", "erase", env=env)
5154
session.run(
55+
"coverage",
56+
"run",
57+
"-m",
5258
"pytest",
53-
"--cov",
54-
"--cov-config",
55-
"pyproject.toml",
56-
"--cov-report=",
5759
"--numprocesses=auto",
5860
"-m",
5961
"not conda",
6062
*session.posargs,
61-
env={
62-
"PYTHONWARNDEFAULTENCODING": "1",
63-
"COVERAGE_FILE": coverage_file,
64-
},
63+
env=env,
6564
)
65+
session.run("coverage", "combine", env=env)
66+
session.run("coverage", "report", env=env)
6667

67-
if sys.platform.startswith("win"):
68-
with contextlib.closing(sqlite3.connect(coverage_file)) as con, con:
69-
con.execute("UPDATE file SET path = REPLACE(path, '\\', '/')")
70-
con.execute("DELETE FROM file WHERE SUBSTR(path, 2, 1) == ':'")
68+
# if sys.platform.startswith("win"):
69+
# with contextlib.closing(sqlite3.connect(coverage_file)) as con, con:
70+
# con.execute("UPDATE file SET path = REPLACE(path, '\\', '/')")
71+
# con.execute("DELETE FROM file WHERE SUBSTR(path, 2, 1) == ':'")
7172

7273

7374
@nox.session(venv_backend="uv", default=False)
@@ -84,6 +85,7 @@ def xonda_tests(session: nox.Session, xonda: str) -> None:
8485
"""Run test suite set up with conda/mamba/etc."""
8586

8687
coverage_file = f".coverage.{xonda}.{sys.platform}.{session.python}"
88+
env = {"COVERAGE_FILE": coverage_file}
8789

8890
session.conda_install(
8991
"--file", "requirements-conda-test.txt", channel="conda-forge"
@@ -92,17 +94,20 @@ def xonda_tests(session: nox.Session, xonda: str) -> None:
9294
# Currently, this doesn't work on Windows either with or without quoting
9395
if not sys.platform.startswith("win32"):
9496
session.conda_install("requests<99")
97+
98+
session.run("coverage", "erase", env=env)
9599
session.run(
100+
"coverage",
101+
"run",
102+
"-m",
96103
"pytest",
97-
"--cov",
98-
"--cov-config",
99-
"pyproject.toml",
100-
"--cov-report=",
101104
"-m",
102105
"conda",
103106
*session.posargs,
104-
env={"COVERAGE_FILE": coverage_file},
107+
env=env,
105108
)
109+
session.run("coverage", "combine", env=env)
110+
session.run("coverage", "report", env=env)
106111

107112

108113
@nox.session(venv_backend="conda", default=bool(shutil.which("conda")))

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ test = [
7474
"coverage[toml]>=7.10.3",
7575
"pytest>=7.4; python_version>='3.12'",
7676
"pytest>=7; python_version<'3.12'",
77-
"pytest-cov>=3",
7877
"pytest-xdist>=3",
7978
]
8079
docs = [
@@ -160,7 +159,7 @@ run.core = "sysmon"
160159
run.branch = true
161160
run.patch = [ "subprocess" ]
162161
run.relative_files = true
163-
run.source_pkgs = [ "nox" ]
162+
run.source_dirs = [ "nox" ]
164163
run.disable_warnings = [
165164
"no-sysmon",
166165
]

0 commit comments

Comments
 (0)