Skip to content

Commit 57bcf4c

Browse files
committed
cuda.core.texture: fix stale address_mode entry-rejection test (NVIDIA#2292)
The StrEnum migration (item 4 of NVIDIA#2292) makes a plain str acceptable anywhere an AddressModeType is expected. A bad tuple entry like "bad" is therefore a valid *type* but an invalid *value*, so _normalize_enum rejects it with a ValueError (naming the offending position address_mode[1]), not a TypeError. Update the test to assert ValueError and rename it to test_address_mode_rejects_invalid_entry. This is the second of the two CI failures on PR NVIDIA#2307; the first (the stale options-type message) was fixed in the previous commit.
1 parent 16940d7 commit 57bcf4c

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎cuda_core/tests/test_texture_surface.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -967,12 +967,15 @@ def test_address_mode_rejects_too_long_tuple(init_cuda):
967967
arr.close()
968968

969969

970-
def test_address_mode_rejects_non_addressmode_entry(init_cuda):
970+
def test_address_mode_rejects_invalid_entry(init_cuda):
971971
arr = Device().create_opaque_array(OpaqueArrayOptions(shape=(8, 8), format=ArrayFormatType.FLOAT32, num_channels=1))
972972
try:
973973
res = ResourceDescriptor.from_opaque_array(arr)
974+
# "bad" is a valid *type* (str is accepted anywhere an AddressModeType
975+
# is) but an invalid *value*, so it is rejected with a ValueError naming
976+
# the offending tuple position.
974977
td = TextureObjectOptions(address_mode=(AddressModeType.WRAP, "bad", AddressModeType.CLAMP))
975-
with pytest.raises(TypeError, match=r"address_mode\[1\]"):
978+
with pytest.raises(ValueError, match=r"address_mode\[1\]"):
976979
Device().create_texture_object(resource=res, options=td)
977980
finally:
978981
arr.close()

0 commit comments

Comments
 (0)