@@ -58,7 +58,10 @@ def test_address_of():
58
58
"""
59
59
Test if the address_of method returns an int value.
60
60
"""
61
- ctx = dpctl .SyclContext ()
61
+ try :
62
+ ctx = dpctl .SyclContext ()
63
+ except dpctl .SyclContextCreationError :
64
+ pytest .skip ("Failed to create context using default constructor" )
62
65
assert ctx .addressof_ref () is not None
63
66
assert isinstance (ctx .addressof_ref (), int )
64
67
@@ -85,7 +88,10 @@ def test_context_not_equals2():
85
88
Test if comparing a SyclContext object to some random Python object is
86
89
correctly handled and returns False.
87
90
"""
88
- ctx = dpctl .SyclContext ()
91
+ try :
92
+ ctx = dpctl .SyclContext ()
93
+ except dpctl .SyclContextCreationError :
94
+ pytest .skip ("Failed to create context using default constructor" )
89
95
assert ctx != "some context"
90
96
91
97
@@ -103,15 +109,21 @@ def test_name():
103
109
"""
104
110
Test if a __name__ method is defined for SyclContext.
105
111
"""
106
- ctx = dpctl .SyclContext ()
112
+ try :
113
+ ctx = dpctl .SyclContext ()
114
+ except dpctl .SyclContextCreationError :
115
+ pytest .skip ("Failed to create context using default constructor" )
107
116
assert ctx .__name__ == "SyclContext"
108
117
109
118
110
119
def test_repr ():
111
120
"""
112
121
Test if a __repr__ method is defined for SyclContext.
113
122
"""
114
- ctx = dpctl .SyclContext ()
123
+ try :
124
+ ctx = dpctl .SyclContext ()
125
+ except dpctl .SyclContextCreationError :
126
+ pytest .skip ("Failed to create context using default constructor" )
115
127
assert ctx .__repr__ is not None
116
128
117
129
@@ -181,20 +193,30 @@ def test_hashing_of_context():
181
193
as a dictionary key.
182
194
183
195
"""
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" }
185
201
assert ctx_dict
186
202
187
203
188
204
def 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" )
190
209
assert type (ctx .__repr__ ()) is str
191
210
192
211
193
212
def test_cpython_api_SyclContext_GetContextRef ():
194
213
import ctypes
195
214
import sys
196
215
197
- ctx = dpctl .SyclContext ()
216
+ try :
217
+ ctx = dpctl .SyclContext ()
218
+ except dpctl .SyclContextCreationError :
219
+ pytest .skip ("Failed to create context using default constructor" )
198
220
mod = sys .modules [ctx .__class__ .__module__ ]
199
221
# get capsule storign SyclContext_GetContextRef function ptr
200
222
ctx_ref_fn_cap = mod .__pyx_capi__ ["SyclContext_GetContextRef" ]
@@ -217,7 +239,10 @@ def test_cpython_api_SyclContext_Make():
217
239
import ctypes
218
240
import sys
219
241
220
- ctx = dpctl .SyclContext ()
242
+ try :
243
+ ctx = dpctl .SyclContext ()
244
+ except dpctl .SyclContextCreationError :
245
+ pytest .skip ("Failed to create context using default constructor" )
221
246
mod = sys .modules [ctx .__class__ .__module__ ]
222
247
# get capsule storign SyclContext_Make function ptr
223
248
make_ctx_fn_cap = mod .__pyx_capi__ ["SyclContext_Make" ]
@@ -243,6 +268,8 @@ def test_invalid_capsule():
243
268
244
269
def test_multi_device_different_platforms ():
245
270
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 :
247
272
with pytest .raises (dpctl .SyclContextCreationError ):
248
273
dpctl .SyclContext (devs )
274
+ else :
275
+ pytest .skip ("Insufficient amount of available devices for this test" )
0 commit comments