Skip to content

Commit 8ebfde7

Browse files
Handle device creation exceptions
1 parent 6eb7421 commit 8ebfde7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

dpctl/tests/test_usm_ndarray_print.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import pytest
1919
from helper import get_queue_or_skip, skip_if_dtype_not_supported
2020

21+
import dpctl
2122
import dpctl.tensor as dpt
2223

2324

@@ -53,7 +54,10 @@ def test_usm_ndarray_repr_arg_validation(self):
5354
with pytest.raises(TypeError):
5455
dpt.usm_ndarray_repr(X)
5556

56-
X = dpt.arange(4)
57+
try:
58+
X = dpt.arange(4)
59+
except dpctl.SyclDeviceCreationError:
60+
pytest.skip("No SYCL devices available")
5761
with pytest.raises(TypeError):
5862
dpt.usm_ndarray_repr(X, line_width="I")
5963

@@ -68,7 +72,11 @@ def test_usm_ndarray_str_arg_validation(self):
6872
with pytest.raises(TypeError):
6973
dpt.usm_ndarray_str(X)
7074

71-
X = dpt.arange(4)
75+
try:
76+
X = dpt.arange(4)
77+
except dpctl.SyclDeviceCreationError:
78+
pytest.skip("No SYCL devices available")
79+
7280
with pytest.raises(TypeError):
7381
dpt.usm_ndarray_str(X, line_width="I")
7482

@@ -363,8 +371,12 @@ def test_usm_ndarray_repr_prefix(self):
363371
class TestContextManager:
364372
def test_context_manager_basic(self):
365373
options = dpt.get_print_options()
374+
try:
375+
X = dpt.asarray(1.234567)
376+
except dpctl.SyclDeviceCreationError:
377+
pytest.skip("No SYCL devices available")
366378
with dpt.print_options(precision=4):
367-
s = str(dpt.asarray(1.234567))
379+
s = str(X)
368380
assert s == "1.2346"
369381
assert options == dpt.get_print_options()
370382

0 commit comments

Comments
 (0)