From cb574755453448be8be3e8f257f66a4a3418a555 Mon Sep 17 00:00:00 2001 From: Ned Molter Date: Wed, 12 Feb 2025 17:22:48 -0500 Subject: [PATCH] bad syntax for pytest.raises --- src/stdatamodels/jwst/datamodels/tests/test_models.py | 4 +++- tests/test_fits.py | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/stdatamodels/jwst/datamodels/tests/test_models.py b/src/stdatamodels/jwst/datamodels/tests/test_models.py index 49c778fd..1117cc14 100644 --- a/src/stdatamodels/jwst/datamodels/tests/test_models.py +++ b/src/stdatamodels/jwst/datamodels/tests/test_models.py @@ -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", ""]] diff --git a/tests/test_fits.py b/tests/test_fits.py index 8d5f84c1..c9429e6a 100644 --- a/tests/test_fits.py +++ b/tests/test_fits.py @@ -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", ""]) @@ -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 @@ -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