Skip to content

Commit

Permalink
bad syntax for pytest.raises
Browse files Browse the repository at this point in the history
  • Loading branch information
emolter committed Feb 12, 2025
1 parent 845569d commit cb57475
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/stdatamodels/jwst/datamodels/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ def test_update_from_datamodel(tmp_path, datamodel_for_update, only, extra_fits)
# Verify the fixture returns keywords we expect
assert oldim.meta.telescope == "JWST"
assert oldim.meta.wcsinfo.crval1 == 5
with pytest.raises(DeprecationWarning, "Manipulation of extra_fits is deprecated"):
with pytest.raises(
DeprecationWarning, match="Manipulation of extra_fits is deprecated"
):
assert oldim.extra_fits.PRIMARY.header == [["FOO", "BAR", ""]]
assert oldim.extra_fits.SCI.header == [["BAZ", "BUZ", ""]]

Expand Down
8 changes: 5 additions & 3 deletions tests/test_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_extra_fits(tmp_path):
hdul.writeto(file_path, overwrite=True)

with DataModel(file_path) as dm:
with pytest.raises(DeprecationWarning, "Manipulation of extra_fits is deprecated"):
with pytest.raises(DeprecationWarning, match="Manipulation of extra_fits is deprecated"):
assert any(h for h in dm.extra_fits.PRIMARY.header if h == ["FOO", "BAR", ""])


Expand Down Expand Up @@ -601,7 +601,7 @@ def test_no_asdf_extension_extra_fits(tmp_path):
}

with PureFitsModel((5, 5)) as m:
with pytest.raises(DeprecationWarning, "Manipulation of extra_fits is deprecated"):
with pytest.raises(DeprecationWarning, match="Manipulation of extra_fits is deprecated"):
m.extra_fits = {}
m.extra_fits.instance.update(extra_fits)
assert "ASDF" in m.extra_fits.instance
Expand All @@ -614,7 +614,9 @@ def test_no_asdf_extension_extra_fits(tmp_path):

with PureFitsModel(path) as m:
with pytest.raises(AttributeError):
with pytest.raises(DeprecationWarning, "Manipulation of extra_fits is deprecated"):
with pytest.raises(
DeprecationWarning, match="Manipulation of extra_fits is deprecated"
):
m.extra_fits # noqa: B018


Expand Down

0 comments on commit cb57475

Please sign in to comment.