tests: fix parametrize patterns rejected by pytest 9.1.0#2212
Draft
leofang wants to merge 1 commit into
Draft
Conversation
Two latent test-code bugs that older pytest tolerated but pytest 9.1.0
flags as collection errors, breaking every Test job on main since the
pytest 9.1.0 release:
* cuda_core/tests/test_utils.py:151 had a stray trailing comma in the
`parametrize` name string (`"in_arr,"`). pytest 9 now splits names on
comma and counts them, mismatching against the multi-element value
tuples. Drop the comma.
* cuda_bindings/tests/test_nvfatbin.py had two tests using
`@pytest.mark.parametrize("arch", ["sm_80"], indirect=True)` to
override the fixture-level `arch` parametrization. pytest 9 now
rejects this combination as "duplicate parametrization of 'arch'".
Extract the CUBIN-building logic into a `_build_cubin(arch)` helper,
drop the indirect override on the two tests, and call the helper
inline with the hardcoded `"sm_80"` they need. Preserves intent (the
override existed because target arch "75" must not match the CUBIN's
arch).
Both fixes are pytest-version-agnostic; verified collecting cleanly
under pytest 9.1.0, 9.0.2, and 8.4.2 with minimal reproductions of
each pattern.
Contributor
rwgk
approved these changes
Jun 14, 2026
rwgk
left a comment
Contributor
There was a problem hiding this comment.
I saw ... it can only get better!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
main has been red since pytest 9.1.0 landed on PyPI — every
Test linux-*/Test win-*matrix entry fails at pytest collection time, before any actual test runs. Two unrelated latent bugs in our test code, both tolerated by older pytest but rejected by pytest 9.1.0's stricterparametrizevalidation:Bug 1: trailing comma in
parametrizename (cuda_core)cuda_core/tests/test_utils.py:151had:@pytest.mark.parametrize("in_arr,", _cpu_array_samples())The
,inside the string was a stray. pytest 9 splits names on comma, ends up with one name but 3-tuple values, and fails collection with:Fix: drop the trailing comma.
Bug 2:
indirect=Trueoverride of a fixture-level parametrize (cuda_bindings)cuda_bindings/tests/test_nvfatbin.pyhas anarchfixture parametrized withparams=ARCHITECTURES. Two tests overrode it via@pytest.mark.parametrize("arch", ["sm_80"], indirect=True). pytest 9 now rejects this as:Fix: extract the CUBIN-building logic from the
CUBINfixture into a_build_cubin(arch)helper, drop theindirectoverride on the two affected tests, and call the helper directly with"sm_80"(preserving the original intent — those tests intentionally used only sm_80, since target arch"75"must not match the CUBIN's arch).Backwards compatibility
Both fixes are pytest-version-agnostic — pip pin (
pytest>=6.2.4) doesn't need to change. Verified by collecting against three pytest versions (minimal repros, included below for reproducibility):Reference
Affected CI runs on main:
Same pattern on my open #2210: https://github.com/NVIDIA/cuda-python/actions/runs/27489049015 — 38
Run cuda.core testsfailures + 23Run cuda.bindings testsfailures all stem from these two collection errors.