Skip to content

Commit 3cc287c

Browse files
committed
Fix test_experimental_direct_imports to handle module caching
[UNTESTED] Clear cached experimental module before testing to ensure warnings are emitted. Also improve assertion message.
1 parent d582448 commit 3cc287c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

cuda_core/tests/test_experimental_backward_compat.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ def test_experimental_symbols_are_same_objects():
5858

5959
def test_experimental_direct_imports():
6060
"""Test that direct imports from experimental submodules work."""
61+
# Clear any cached imports to ensure warnings are emitted
62+
import sys
63+
if 'cuda.core.experimental' in sys.modules:
64+
del sys.modules['cuda.core.experimental']
65+
6166
with warnings.catch_warnings(record=True) as w:
6267
warnings.simplefilter("always")
6368

@@ -68,8 +73,8 @@ def test_experimental_direct_imports():
6873
from cuda.core.experimental import Linker, launch
6974
from cuda.core.experimental import system
7075

71-
# Should have warnings
72-
assert len(w) >= 1
76+
# Should have warnings (at least one from the initial import)
77+
assert len(w) >= 1, f"Expected at least 1 deprecation warning, got {len(w)}"
7378

7479
# Verify objects are usable
7580
assert Device is not None

0 commit comments

Comments
 (0)