@@ -58,7 +58,10 @@ def test_address_of():
5858 """
5959 Test if the address_of method returns an int value.
6060 """
61- ctx = dpctl .SyclContext ()
61+ try :
62+ ctx = dpctl .SyclContext ()
63+ except dpctl .SyclContextCreationError :
64+ pytest .skip ("Failed to create context using default constructor" )
6265 assert ctx .addressof_ref () is not None
6366 assert isinstance (ctx .addressof_ref (), int )
6467
@@ -85,7 +88,10 @@ def test_context_not_equals2():
8588 Test if comparing a SyclContext object to some random Python object is
8689 correctly handled and returns False.
8790 """
88- ctx = dpctl .SyclContext ()
91+ try :
92+ ctx = dpctl .SyclContext ()
93+ except dpctl .SyclContextCreationError :
94+ pytest .skip ("Failed to create context using default constructor" )
8995 assert ctx != "some context"
9096
9197
@@ -103,15 +109,21 @@ def test_name():
103109 """
104110 Test if a __name__ method is defined for SyclContext.
105111 """
106- ctx = dpctl .SyclContext ()
112+ try :
113+ ctx = dpctl .SyclContext ()
114+ except dpctl .SyclContextCreationError :
115+ pytest .skip ("Failed to create context using default constructor" )
107116 assert ctx .__name__ == "SyclContext"
108117
109118
110119def test_repr ():
111120 """
112121 Test if a __repr__ method is defined for SyclContext.
113122 """
114- ctx = dpctl .SyclContext ()
123+ try :
124+ ctx = dpctl .SyclContext ()
125+ except dpctl .SyclContextCreationError :
126+ pytest .skip ("Failed to create context using default constructor" )
115127 assert ctx .__repr__ is not None
116128
117129
@@ -181,20 +193,30 @@ def test_hashing_of_context():
181193 as a dictionary key.
182194
183195 """
184- ctx_dict = {dpctl .SyclContext (): "default_context" }
196+ try :
197+ ctx = dpctl .SyclContext ()
198+ except dpctl .SyclContextCreationError :
199+ pytest .skip ("Failed to create context using default constructor" )
200+ ctx_dict = {ctx : "default_context" }
185201 assert ctx_dict
186202
187203
188204def test_context_repr ():
189- ctx = dpctl .SyclContext ()
205+ try :
206+ ctx = dpctl .SyclContext ()
207+ except dpctl .SyclContextCreationError :
208+ pytest .skip ("Failed to create context using default constructor" )
190209 assert type (ctx .__repr__ ()) is str
191210
192211
193212def test_cpython_api_SyclContext_GetContextRef ():
194213 import ctypes
195214 import sys
196215
197- ctx = dpctl .SyclContext ()
216+ try :
217+ ctx = dpctl .SyclContext ()
218+ except dpctl .SyclContextCreationError :
219+ pytest .skip ("Failed to create context using default constructor" )
198220 mod = sys .modules [ctx .__class__ .__module__ ]
199221 # get capsule storign SyclContext_GetContextRef function ptr
200222 ctx_ref_fn_cap = mod .__pyx_capi__ ["SyclContext_GetContextRef" ]
@@ -217,7 +239,10 @@ def test_cpython_api_SyclContext_Make():
217239 import ctypes
218240 import sys
219241
220- ctx = dpctl .SyclContext ()
242+ try :
243+ ctx = dpctl .SyclContext ()
244+ except dpctl .SyclContextCreationError :
245+ pytest .skip ("Failed to create context using default constructor" )
221246 mod = sys .modules [ctx .__class__ .__module__ ]
222247 # get capsule storign SyclContext_Make function ptr
223248 make_ctx_fn_cap = mod .__pyx_capi__ ["SyclContext_Make" ]
@@ -243,6 +268,8 @@ def test_invalid_capsule():
243268
244269def test_multi_device_different_platforms ():
245270 devs = dpctl .get_devices () # all devices
246- if len (devs ) > 1 :
271+ if len (devs ) > 1 and len ( set ( d . sycl_platform for d in devs )) > 1 :
247272 with pytest .raises (dpctl .SyclContextCreationError ):
248273 dpctl .SyclContext (devs )
274+ else :
275+ pytest .skip ("Insufficient amount of available devices for this test" )
0 commit comments