Skip to content

Commit

Permalink
Add match statements for pytest.raises
Browse files Browse the repository at this point in the history
  • Loading branch information
larrybradley committed Aug 8, 2024
1 parent 592538e commit 9a8d93e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lacosmic/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pytest
from numpy.testing import assert_allclose, assert_array_equal

from ..core import lacosmic
from lacosmic.core import lacosmic

size = 25
npts = 20
Expand Down Expand Up @@ -93,13 +93,15 @@ def test_error_image_size(self):
image.
"""
error = np.zeros((7, 7))
with pytest.raises(ValueError):
match = 'error and data must have the same shape'
with pytest.raises(ValueError, match=match):
lacosmic(CR_IMG, 3, 2, 2, effective_gain=1, readnoise=0,
error=error)

def test_error_inputs(self):
with pytest.raises(ValueError):
match = 'effective_gain and readnoise must be input if error is not'
with pytest.raises(ValueError, match=match):
lacosmic(CR_IMG, 3, 2, 2, effective_gain=1, error=None)

with pytest.raises(ValueError):
with pytest.raises(ValueError, match=match):
lacosmic(CR_IMG, 3, 2, 2, readnoise=0, error=None)

0 comments on commit 9a8d93e

Please sign in to comment.