99correctly and emit appropriate deprecation warnings.
1010"""
1111
12- import warnings
13-
1412import pytest
1513
14+
1615# Test that experimental imports still work
1716def test_experimental_imports_work ():
1817 """Test that imports from experimental namespace still work."""
1918 # Clear cached module to ensure warning is emitted
2019 import sys
21- if 'cuda.core.experimental' in sys .modules :
22- del sys .modules ['cuda.core.experimental' ]
23-
20+
21+ if "cuda.core.experimental" in sys .modules :
22+ del sys .modules ["cuda.core.experimental" ]
23+
2424 # Test main module import - should emit deprecation warning
2525 with pytest .deprecated_call ():
2626 import cuda .core .experimental
27-
27+
2828 # Test that symbols are accessible
2929 assert hasattr (cuda .core .experimental , "Device" )
3030 assert hasattr (cuda .core .experimental , "Stream" )
@@ -36,7 +36,7 @@ def test_experimental_symbols_are_same_objects():
3636 """Test that experimental namespace symbols are the same objects as core."""
3737 import cuda .core
3838 import cuda .core .experimental
39-
39+
4040 # Compare classes/types
4141 assert cuda .core .experimental .Device is cuda .core .Device
4242 assert cuda .core .experimental .Stream is cuda .core .Stream
@@ -49,7 +49,7 @@ def test_experimental_symbols_are_same_objects():
4949 assert cuda .core .experimental .GraphBuilder is cuda .core .GraphBuilder
5050 assert cuda .core .experimental .Event is cuda .core .Event
5151 assert cuda .core .experimental .Linker is cuda .core .Linker
52-
52+
5353 # Compare singletons
5454 assert cuda .core .experimental .system is cuda .core .system
5555
@@ -58,17 +58,18 @@ def test_experimental_direct_imports():
5858 """Test that direct imports from experimental submodules work."""
5959 # Clear any cached imports to ensure warnings are emitted
6060 import sys
61- if 'cuda.core.experimental' in sys .modules :
62- del sys .modules ['cuda.core.experimental' ]
63-
61+
62+ if "cuda.core.experimental" in sys .modules :
63+ del sys .modules ["cuda.core.experimental" ]
64+
6465 # Test various import patterns - warning is emitted once at module import time
6566 with pytest .deprecated_call ():
66- from cuda .core .experimental import Device , Stream , Buffer
67- from cuda . core . experimental import Program , Kernel , ObjectCode
68- from cuda . core . experimental import Graph , GraphBuilder , Event
69- from cuda . core . experimental import Linker , launch
70- from cuda . core . experimental import system
71-
67+ from cuda .core .experimental import (
68+ Buffer ,
69+ Device ,
70+ Stream ,
71+ )
72+
7273 # Verify objects are usable
7374 assert Device is not None
7475 assert Stream is not None
@@ -78,7 +79,7 @@ def test_experimental_direct_imports():
7879def test_experimental_submodule_access ():
7980 """Test that accessing experimental submodules works."""
8081 import cuda .core .experimental
81-
82+
8283 # Test that submodules can be accessed (via __getattr__)
8384 # Note: These may not exist as actual modules, but the forwarding should work
8485 try :
@@ -94,28 +95,29 @@ def test_experimental_submodule_access():
9495
9596def test_experimental_utils_module ():
9697 """Test that experimental.utils module works.
97-
98+
9899 Note: The deprecation warning is only emitted once at import time when
99100 cuda.core.experimental is first imported. Accessing utils or importing
100101 from utils does not trigger additional warnings since utils is already
101102 set as an attribute in the module namespace.
102103 """
103104 import cuda .core .experimental
104-
105+
105106 # Should be able to access utils (no warning on access, only on initial import)
106107 assert hasattr (cuda .core .experimental , "utils" )
107108 assert cuda .core .experimental .utils is not None
108-
109+
109110 # Should have expected utilities (no warning on import from utils submodule)
110111 from cuda .core .experimental .utils import StridedMemoryView , args_viewable_as_strided_memory
112+
111113 assert StridedMemoryView is not None
112114 assert args_viewable_as_strided_memory is not None
113115
114116
115117def test_experimental_options_classes ():
116118 """Test that options classes are accessible."""
117119 import cuda .core .experimental
118-
120+
119121 assert hasattr (cuda .core .experimental , "EventOptions" )
120122 assert hasattr (cuda .core .experimental , "StreamOptions" )
121123 assert hasattr (cuda .core .experimental , "LaunchConfig" )
@@ -125,7 +127,7 @@ def test_experimental_options_classes():
125127 assert hasattr (cuda .core .experimental , "GraphDebugPrintOptions" )
126128 assert hasattr (cuda .core .experimental , "DeviceMemoryResourceOptions" )
127129 assert hasattr (cuda .core .experimental , "VirtualMemoryResourceOptions" )
128-
130+
129131 # Verify they're the same objects
130132 assert cuda .core .experimental .EventOptions is cuda .core .EventOptions
131133 assert cuda .core .experimental .StreamOptions is cuda .core .StreamOptions
@@ -135,13 +137,13 @@ def test_experimental_options_classes():
135137def test_experimental_memory_classes ():
136138 """Test that memory-related classes are accessible."""
137139 import cuda .core .experimental
138-
140+
139141 assert hasattr (cuda .core .experimental , "MemoryResource" )
140142 assert hasattr (cuda .core .experimental , "DeviceMemoryResource" )
141143 assert hasattr (cuda .core .experimental , "LegacyPinnedMemoryResource" )
142144 assert hasattr (cuda .core .experimental , "VirtualMemoryResource" )
143145 assert hasattr (cuda .core .experimental , "GraphMemoryResource" )
144-
146+
145147 # Verify they're the same objects
146148 assert cuda .core .experimental .MemoryResource is cuda .core .MemoryResource
147149 assert cuda .core .experimental .DeviceMemoryResource is cuda .core .DeviceMemoryResource
@@ -151,11 +153,12 @@ def test_experimental_memory_classes():
151153def test_experimental_instantiations ():
152154 """Test that objects can be instantiated through experimental namespace."""
153155 from cuda .core .experimental import Device
154-
156+
155157 # Should be able to create objects
156158 device = Device ()
157159 assert device is not None
158-
160+
159161 # Verify it's the same type
160162 from cuda .core import Device as CoreDevice
163+
161164 assert isinstance (device , CoreDevice )
0 commit comments