From fadd5bd7cf3a39ad7061fef46495e29ee5fc23a0 Mon Sep 17 00:00:00 2001 From: Leo Fang Date: Sun, 14 Jun 2026 07:11:06 +0000 Subject: [PATCH] tests: fix parametrize patterns rejected by pytest 9.1.0 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. --- cuda_bindings/tests/test_nvfatbin.py | 20 ++++++++++++-------- cuda_core/tests/test_utils.py | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cuda_bindings/tests/test_nvfatbin.py b/cuda_bindings/tests/test_nvfatbin.py index 32c6e70f59..ec2f17ef95 100644 --- a/cuda_bindings/tests/test_nvfatbin.py +++ b/cuda_bindings/tests/test_nvfatbin.py @@ -121,8 +121,7 @@ def nvcc_smoke(tmpdir) -> str: return nvcc -@pytest.fixture -def CUBIN(arch): +def _build_cubin(arch): def CHECK_NVRTC(err): if err != nvrtc.nvrtcResult.NVRTC_SUCCESS: raise RuntimeError(repr(err)) @@ -141,6 +140,11 @@ def CHECK_NVRTC(err): return cubin +@pytest.fixture +def CUBIN(arch): + return _build_cubin(arch) + + # create a valid LTOIR input for testing @pytest.fixture def LTOIR(arch): @@ -259,11 +263,11 @@ def test_nvfatbin_add_ptx(PTX, arch): nvfatbin.destroy(handle) -@pytest.mark.parametrize("arch", ["sm_80"], indirect=True) -def test_nvfatbin_add_cubin_ELF_SIZE_MISMATCH(CUBIN, arch): +def test_nvfatbin_add_cubin_ELF_SIZE_MISMATCH(): + cubin = _build_cubin("sm_80") handle = nvfatbin.create([], 0) with pytest.raises(nvfatbin.nvFatbinError, match="ERROR_ELF_ARCH_MISMATCH"): - nvfatbin.add_cubin(handle, CUBIN, len(CUBIN), "75", "inc") + nvfatbin.add_cubin(handle, cubin, len(cubin), "75", "inc") nvfatbin.destroy(handle) @@ -280,11 +284,11 @@ def test_nvfatbin_add_cubin(CUBIN, arch): nvfatbin.destroy(handle) -@pytest.mark.parametrize("arch", ["sm_80"], indirect=True) -def test_nvfatbin_add_cubin_ELF_ARCH_MISMATCH(CUBIN, arch): +def test_nvfatbin_add_cubin_ELF_ARCH_MISMATCH(): + cubin = _build_cubin("sm_80") handle = nvfatbin.create([], 0) with pytest.raises(nvfatbin.nvFatbinError, match="ERROR_ELF_ARCH_MISMATCH"): - nvfatbin.add_cubin(handle, CUBIN, len(CUBIN), "75", "inc") + nvfatbin.add_cubin(handle, cubin, len(cubin), "75", "inc") nvfatbin.destroy(handle) diff --git a/cuda_core/tests/test_utils.py b/cuda_core/tests/test_utils.py index 3d4059b696..54b3cc949b 100644 --- a/cuda_core/tests/test_utils.py +++ b/cuda_core/tests/test_utils.py @@ -148,7 +148,7 @@ def _cpu_array_samples(): return samples -@pytest.mark.parametrize("in_arr,", _cpu_array_samples()) +@pytest.mark.parametrize("in_arr", _cpu_array_samples()) class TestViewCPU: def test_args_viewable_as_strided_memory_cpu(self, in_arr): @args_viewable_as_strided_memory((0,))