Skip to content

Commit

Permalink
Add checking of log messages with pytest caplog
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfeickert committed Mar 5, 2019
1 parent 8e51b8f commit 23d8e13
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/test_tensor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import pytest
import logging
import numpy as np
import pyhf
from pyhf.simplemodels import hepdata_like


def test_astensor_dtype(backend):
def test_astensor_dtype(backend, caplog):
tb = pyhf.tensorlib
with pytest.raises(KeyError):
assert tb.astensor([1, 2, 3], dtype='long')
with caplog.at_level(logging.INFO, 'pyhf.tensor'):
with pytest.raises(KeyError):
assert tb.astensor([1, 2, 3], dtype='long')
assert 'Invalid dtype' in caplog.text


def test_simple_tensor_ops(backend):
Expand Down

0 comments on commit 23d8e13

Please sign in to comment.