Skip to content

Commit

Permalink
test: fix incorrect use of pytest.raises
Browse files Browse the repository at this point in the history
Old tests contained unreachable check for exception messages.
  • Loading branch information
riddell-stan committed Feb 25, 2019
1 parent 733de3e commit 3313ed5
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions tests/test_basic_bernoulli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ def fit(posterior):
def test_bernoulli_sampling_error():
bad_data = data.copy()
del bad_data["N"]
with pytest.raises(RuntimeError) as exc_info:
with pytest.raises(RuntimeError, match=r"variable does not exist"):
stan.build(program_code, data=bad_data)
assert "variable does not exist" in str(exc_info.value)


def test_bernoulli_sampling_thin(posterior):
Expand All @@ -45,9 +44,8 @@ def test_bernoulli_sampling_thin(posterior):


def test_bernoulli_sampling_invalid_argument(posterior):
with pytest.raises(TypeError) as exc_info:
with pytest.raises(TypeError, match=r"'float' object cannot be interpreted as an integer"):
posterior.sample(num_thin=2.0)
assert "only integer values allowed" in str(exc_info.value)


def test_bernoulli_sampling(fit):
Expand Down

0 comments on commit 3313ed5

Please sign in to comment.