Skip to content

Commit 91a3211

Browse files
cuda.core: relax kw-only TypeError regex for Cython funcs (NVIDIA#2001)
Cython-generated functions raise "FUNC() needs keyword-only argument stream" while pure-Python functions raise "FUNC() missing 1 required keyword-only argument: 'stream'" The new tests for `Kernel.occupancy.max_potential_cluster_size`, `Kernel.occupancy.max_active_clusters`, and `GraphicsResource.map` were matching only the CPython phrasing and failed against the Cython forms. Loosen the regex to `keyword-only argument`, which matches both. Co-authored-by: Cursor <[email protected]>
1 parent 5fd0958 commit 91a3211

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎cuda_core/tests/test_graphics.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def test_map_requires_explicit_stream(self):
341341
with _gl_context_and_buffer(nbytes=4096) as (gl_buf, _):
342342
resource = GraphicsResource.from_gl_buffer(gl_buf, flags="write_discard")
343343
try:
344-
with pytest.raises(TypeError, match="missing .* required keyword-only argument"):
344+
with pytest.raises(TypeError, match=r"keyword-only argument"):
345345
resource.map()
346346
finally:
347347
resource.close()

‎cuda_core/tests/test_module.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def test_occupancy_max_active_clusters(get_saxpy_kernel_cubin, cluster):
488488
pytest.skip("Device with compute capability 90 or higher is required for cluster support")
489489
launch_config = cuda.core.LaunchConfig(grid=128, block=64, cluster=cluster)
490490
query_fn = kernel.occupancy.max_active_clusters
491-
with pytest.raises(TypeError, match="missing .* required keyword-only argument"):
491+
with pytest.raises(TypeError, match=r"keyword-only argument"):
492492
query_fn(launch_config)
493493
max_active_clusters = query_fn(launch_config, stream=dev.default_stream)
494494
assert isinstance(max_active_clusters, int)
@@ -502,7 +502,7 @@ def test_occupancy_max_potential_cluster_size(get_saxpy_kernel_cubin):
502502
pytest.skip("Device with compute capability 90 or higher is required for cluster support")
503503
launch_config = cuda.core.LaunchConfig(grid=128, block=64)
504504
query_fn = kernel.occupancy.max_potential_cluster_size
505-
with pytest.raises(TypeError, match="missing .* required keyword-only argument"):
505+
with pytest.raises(TypeError, match=r"keyword-only argument"):
506506
query_fn(launch_config)
507507
max_potential_cluster_size = query_fn(launch_config, stream=dev.default_stream)
508508
assert isinstance(max_potential_cluster_size, int)

0 commit comments

Comments
 (0)