2121
2222from __future__ import annotations
2323
24- import contextlib
2524import functools
2625import os
2726import shutil
28- import sqlite3
2927import sys
3028
3129import 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" )))
0 commit comments