Skip to content

Commit bfbf3f0

Browse files
committed
bump pytest to 9; add pyv to file template; use = for all custom args
adding "test/" to pytest doesnt work because then we can't indicate a specific set of test files. use = for all sqlalchemy-custom parameters instead to avoid [1] [1] pytest-dev/pytest#13913 Change-Id: I9eb5bbfac734fcb145fcf3ae58fcc55df6bb6e71
1 parent 0463f9c commit bfbf3f0

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

noxfile.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
sys.path.insert(0, ".")
1717
from tools.toxnox import tox_parameters
1818
from tools.toxnox import apply_pytest_opts
19-
from tools.toxnox import OUR_PYTHON
2019

2120

2221
SQLA_REPO = os.environ.get(
@@ -65,7 +64,6 @@ def filter_sqla(
6564
)
6665
def tests(
6766
session: nox.Session,
68-
python: str,
6967
sqlalchemy: str,
7068
database: str,
7169
backendonly: str,
@@ -76,7 +74,6 @@ def tests(
7674
session,
7775
sqlalchemy,
7876
database,
79-
python=python,
8077
backendonly=backendonly == "backendonly",
8178
)
8279

@@ -94,7 +91,6 @@ def _tests(
9491
sqlalchemy: str,
9592
database: str,
9693
*,
97-
python: str = OUR_PYTHON,
9894
coverage: bool = False,
9995
backendonly: bool = False,
10096
) -> None:
@@ -136,21 +132,24 @@ def _tests(
136132

137133
cmd.extend(os.environ.get("TOX_WORKERS", "-n4").split())
138134

135+
# for all sqlalchemy-custom options, use equals sign so that we avoid
136+
# https://github.com/pytest-dev/pytest/issues/13913
137+
139138
match database:
140139
case "sqlite":
141-
cmd.extend(os.environ.get("TOX_SQLITE", "--db sqlite").split())
140+
cmd.extend(os.environ.get("TOX_SQLITE", "--db=sqlite").split())
142141
case "postgresql":
143142
session.install(
144143
*nox.project.dependency_groups(pyproject, "tests_postgresql")
145144
)
146145
cmd.extend(
147-
os.environ.get("TOX_POSTGRESQL", "--db postgresql").split()
146+
os.environ.get("TOX_POSTGRESQL", "--db=postgresql").split()
148147
)
149148
case "mysql":
150149
session.install(
151150
*nox.project.dependency_groups(pyproject, "tests_mysql")
152151
)
153-
cmd.extend(os.environ.get("TOX_MYSQL", "--db mysql").split())
152+
cmd.extend(os.environ.get("TOX_MYSQL", "--db=mysql").split())
154153
case "oracle":
155154
# we'd like to use oracledb but SQLAlchemy 1.4 does not have
156155
# oracledb support...
@@ -161,14 +160,14 @@ def _tests(
161160
session.env["ORACLE_HOME"] = os.environ.get("ORACLE_HOME")
162161
if "NLS_LANG" in os.environ:
163162
session.env["NLS_LANG"] = os.environ.get("NLS_LANG")
164-
cmd.extend(os.environ.get("TOX_ORACLE", "--db oracle").split())
165-
cmd.extend("--write-idents db_idents.txt".split())
163+
cmd.extend(os.environ.get("TOX_ORACLE", "--db=oracle").split())
164+
cmd.append("--write-idents=db_idents.txt")
166165
case "mssql":
167166
session.install(
168167
*nox.project.dependency_groups(pyproject, "tests_mssql")
169168
)
170-
cmd.extend(os.environ.get("TOX_MSSQL", "--db mssql").split())
171-
cmd.extend("--write-idents db_idents.txt".split())
169+
cmd.extend(os.environ.get("TOX_MSSQL", "--db=mssql").split())
170+
cmd.append("--write-idents=db_idents.txt")
172171

173172
if backendonly:
174173
cmd.append("--backend-only")

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ alembic = "alembic.config:main"
5252

5353
[dependency-groups]
5454
tests = [
55-
"pytest>8,<8.4",
55+
"pytest>8,<10",
5656
"pytest-xdist",
5757
"black==25.1.0", # for test_post_write.py
5858
"tzdata",
@@ -83,7 +83,7 @@ lint = [
8383
mypy = [
8484
"mypy>=1.16.0",
8585
"nox", # because we check noxfile.py
86-
"pytest>8,<8.4", # alembic/testing imports pytest
86+
"pytest>8,<10", # alembic/testing imports pytest
8787
]
8888

8989
[tool.coverage.paths]

tools/toxnox.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ def apply_pytest_opts(
216216
) -> list[str]:
217217
posargs, opts = extract_opts(session.posargs, "generate-junit")
218218

219+
if session.python and isinstance(session.python, str):
220+
python_token = session.python.replace(".", "")
221+
tokens.insert(0, python_token)
222+
219223
file_suffix = "-".join(t for t in tokens if not t.startswith("_"))
220224

221225
if coverage:

0 commit comments

Comments
 (0)