Skip to content

Commit

Permalink
Merge pull request #184 from ami-iit/update_exception_test
Browse files Browse the repository at this point in the history
Update exceptions test
  • Loading branch information
diegoferigo committed Jun 19, 2024
2 parents 5e4adaa + 472bc6c commit 3359e9a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/test_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ def jit_compiled_function(data: jax.Array) -> jax.Array:
assert jit_compiled_function._cache_size() == 1

# Let's trigger a ValueError exception by passing 42.
# Note: the real ValueError is printed in a stream that I couldn't figure out
# how to capture in pytest.
with pytest.raises(jaxlib.xla_extension.XlaRuntimeError):

data = 42
data = 42
with pytest.raises(
jaxlib.xla_extension.XlaRuntimeError,
match=f"ValueError: Raising ValueError since data={data}",
):
_ = jit_compiled_function(data=data)

assert jit_compiled_function._cache_size() == 1

# Let's trigger a RuntimeError exception by passing -42.
# Note: the real RuntimeError is printed in a stream that I couldn't figure out
# how to capture in pytest.
with pytest.raises(jaxlib.xla_extension.XlaRuntimeError):

data = -42
data = -42
with pytest.raises(
jaxlib.xla_extension.XlaRuntimeError,
match=f"RuntimeError: Raising RuntimeError since data={data}",
):
_ = jit_compiled_function(data=data)

assert jit_compiled_function._cache_size() == 1

0 comments on commit 3359e9a

Please sign in to comment.