Skip to content

Commit

Permalink
Use pytest.raises instead of the raises argument to pytest.mark.xfail
Browse files Browse the repository at this point in the history
This is more appropriate for the use case.

From the pytest docs:
Using pytest.raises is likely to be better for cases where you are
testing exceptions your own code is deliberately raising, whereas using
@pytest.mark.xfail with a check function is probably better for
something like documenting unfixed bugs (where the test describes what
"should" happen) or bugs in dependencies.

c.f.
https://docs.pytest.org/en/latest/assert.html#assertions-about-expected-exceptions
  • Loading branch information
matthewfeickert committed Mar 5, 2019
1 parent 05d8768 commit 8e51b8f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from pyhf.simplemodels import hepdata_like


@pytest.mark.xfail(raises=KeyError)
def test_astensor_dtype(backend):
tb = pyhf.tensorlib
assert tb.astensor([1, 2, 3], dtype='long')
with pytest.raises(KeyError):
assert tb.astensor([1, 2, 3], dtype='long')


def test_simple_tensor_ops(backend):
Expand Down

0 comments on commit 8e51b8f

Please sign in to comment.