Skip to content

Commit a95dc9e

Browse files
committed
fix: update test_read_only_kernel_attributes for property API (#1945)
The parametrized test in test_module.py exercised the previous KernelAttributes(method, optional device_id) shape via getattr() + call. Rewrite it to use property access on the default view and on the per-device views returned by kernel.attributes[device], for both Device-object and ordinal-int forms. Type-check the value at every access path rather than just the last one. Made-with: Cursor
1 parent a42739f commit a95dc9e

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

cuda_core/tests/test_module.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,18 @@ def test_get_kernel(init_cuda):
207207
)
208208
def test_read_only_kernel_attributes(get_saxpy_kernel_cubin, attr, expected_type):
209209
kernel, _ = get_saxpy_kernel_cubin
210-
method = getattr(kernel.attributes, attr)
211-
# get the value without providing a device ordinal
212-
value = method()
210+
211+
# Default view: property access on the current-device view.
212+
value = getattr(kernel.attributes, attr)
213213
assert value is not None
214+
assert isinstance(value, expected_type), f"Expected {attr} to be of type {expected_type}, but got {type(value)}"
214215

215-
# get the value for each device on the system, using either the device object or ordinal
216+
# Per-device views via __getitem__: each device, both Device and ordinal forms.
216217
for device in Device.get_all_devices():
217-
value = method(device)
218-
value = method(device.device_id)
219-
assert isinstance(value, expected_type), f"Expected {attr} to be of type {expected_type}, but got {type(value)}"
218+
value = getattr(kernel.attributes[device], attr)
219+
assert isinstance(value, expected_type), f"Expected {attr} to be of type {expected_type}, but got {type(value)}"
220+
value = getattr(kernel.attributes[device.device_id], attr)
221+
assert isinstance(value, expected_type), f"Expected {attr} to be of type {expected_type}, but got {type(value)}"
220222

221223

222224
def test_object_code_load_ptx(get_saxpy_kernel_ptx):

0 commit comments

Comments
 (0)