From e250097fb7113be808836a796dc73ba7f687c7b8 Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Wed, 11 Dec 2024 14:44:38 -0500 Subject: [PATCH] Cleanup a photom test (#1536) --- romancal/photom/tests/test_photom.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/romancal/photom/tests/test_photom.py b/romancal/photom/tests/test_photom.py index b3ff879c5..c1de8de2e 100644 --- a/romancal/photom/tests/test_photom.py +++ b/romancal/photom/tests/test_photom.py @@ -1,5 +1,3 @@ -import warnings - import numpy as np import pytest from astropy import units as u @@ -105,19 +103,16 @@ def test_no_photom_match(): input_model.meta.photometry.pixel_area = -1.0 input_model.meta.photometry.conversion_megajanskys = -1.0 - with warnings.catch_warnings(record=True) as caught: + with pytest.warns( + UserWarning, + match=f"No matching photom parameters for {input_model.meta.instrument.optical_element}", + ): # Look for now non existent F146 optical element output_model = photom.apply_photom(input_model, photom_model) - # Assert warning key matches that of the input file - assert ( - str(caught[0].message).split()[-1] - == input_model.meta.instrument.optical_element - ) - - # Assert that photom elements are not updated - assert output_model.meta.photometry.pixel_area == -1.0 - assert output_model.meta.photometry.conversion_megajanskys == -1.0 + # Assert that photom elements are not updated + assert output_model.meta.photometry.pixel_area == -1.0 + assert output_model.meta.photometry.conversion_megajanskys == -1.0 def test_apply_photom1():