diff --git a/src/stdatamodels/jwst/datamodels/tests/test_models.py b/src/stdatamodels/jwst/datamodels/tests/test_models.py index cd3fefde..49c778fd 100644 --- a/src/stdatamodels/jwst/datamodels/tests/test_models.py +++ b/src/stdatamodels/jwst/datamodels/tests/test_models.py @@ -202,8 +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 - assert oldim.extra_fits.PRIMARY.header == [["FOO", "BAR", ""]] - assert oldim.extra_fits.SCI.header == [["BAZ", "BUZ", ""]] + with pytest.raises(DeprecationWarning, "Manipulation of extra_fits is deprecated"): + assert oldim.extra_fits.PRIMARY.header == [["FOO", "BAR", ""]] + assert oldim.extra_fits.SCI.header == [["BAZ", "BUZ", ""]] newim.update(oldim, only=only, extra_fits=extra_fits) newim.save(path) diff --git a/tests/test_fits.py b/tests/test_fits.py index e53fc216..8d5f84c1 100644 --- a/tests/test_fits.py +++ b/tests/test_fits.py @@ -93,7 +93,8 @@ def test_extra_fits(tmp_path): hdul.writeto(file_path, overwrite=True) with DataModel(file_path) as dm: - assert any(h for h in dm.extra_fits.PRIMARY.header if h == ["FOO", "BAR", ""]) + with pytest.raises(DeprecationWarning, "Manipulation of extra_fits is deprecated"): + assert any(h for h in dm.extra_fits.PRIMARY.header if h == ["FOO", "BAR", ""]) def test_hdu_order(tmp_path): @@ -600,11 +601,12 @@ def test_no_asdf_extension_extra_fits(tmp_path): } with PureFitsModel((5, 5)) as m: - m.extra_fits = {} - m.extra_fits.instance.update(extra_fits) - assert "ASDF" in m.extra_fits.instance - assert "CHECKSUM" in m.extra_fits.ASDF.header[0] - assert "DATASUM" in m.extra_fits.ASDF.header[1] + with pytest.raises(DeprecationWarning, "Manipulation of extra_fits is deprecated"): + m.extra_fits = {} + m.extra_fits.instance.update(extra_fits) + assert "ASDF" in m.extra_fits.instance + assert "CHECKSUM" in m.extra_fits.ASDF.header[0] + assert "DATASUM" in m.extra_fits.ASDF.header[1] m.save(path) with fits.open(path, memmap=False) as hdulist: @@ -612,7 +614,8 @@ def test_no_asdf_extension_extra_fits(tmp_path): with PureFitsModel(path) as m: with pytest.raises(AttributeError): - m.extra_fits # noqa: B018 + with pytest.raises(DeprecationWarning, "Manipulation of extra_fits is deprecated"): + m.extra_fits # noqa: B018 def test_ndarray_validation(tmp_path):