Skip to content

Commit 35ac112

Browse files
committed
More rainy day tests
1 parent 37e0aca commit 35ac112

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

dpctl/tests/test_sycl_queue_manager.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ def test_nested_context_factory_is_empty_list():
168168
@contextlib.contextmanager
169169
def _register_nested_context_factory(factory):
170170
dpctl.nested_context_factories.append(factory)
171-
yield
172-
dpctl.nested_context_factories.remove(factory)
171+
try:
172+
yield
173+
finally:
174+
dpctl.nested_context_factories.remove(factory)
173175

174176

175177
def test_register_nested_context_factory_context():
@@ -209,3 +211,19 @@ def factory(_):
209211
assert in_context
210212

211213
assert not in_context
214+
215+
216+
@pytest.mark.parametrize(
217+
"factory, exception, match",
218+
[
219+
(True, TypeError, "object is not callable"),
220+
(lambda x: None, AttributeError, "no attribute '__exit__'"),
221+
],
222+
)
223+
def test_nested_context_factory_exception_if_wrong_factory(
224+
factory, exception, match
225+
):
226+
with pytest.raises(exception, match=match):
227+
with _register_nested_context_factory(factory):
228+
with dpctl.device_context("opencl:gpu:0"):
229+
pass

0 commit comments

Comments
 (0)