Check that warning is raised.
@@ -42,20 +42,28 @@ def test_observation(data_store):
@requires_dependency("matplotlib")
@requires_data()
-def test_observation_peek(data_store):
- obs = data_store.obs(23523)
+def test_observation_peek(data_store, caplog):
+ obs = Observation.read("$GAMMAPY_DATA/hess-dl3-dr1/data/hess_dl3_dr1_obs_id_023523.fits.gz")
with mpl_plot_check():
obs.peek()
obs.bkg = None
+
with mpl_plot_check():
obs.peek()
+ assert "WARNING" in [record.levelname for record in caplog.records]
+ message = "No background model found for obs 23523."
+ assert message in [record.message for record in caplog.records]
+
obs.psf = None
with mpl_plot_check():
obs.peek()
+ assert "WARNING" in [record.levelname for record in caplog.records]
+ message = "No PSF found for obs 23523."
+ assert message in [record.message for record in caplog.records]
@requires_data()
