From cd25270a361f53dc06a144699e094bfb6a9bc1c7 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Wed, 7 Aug 2024 15:57:38 -0700 Subject: [PATCH] Re-enable skipped obscore test Use assertWarns and check for the specific warning. --- tests/test_obscore.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/test_obscore.py b/tests/test_obscore.py index 1095014c1b..e9bb88d610 100644 --- a/tests/test_obscore.py +++ b/tests/test_obscore.py @@ -28,7 +28,6 @@ import os import tempfile import unittest -import warnings from abc import abstractmethod from typing import cast @@ -48,6 +47,7 @@ ObsCoreConfig, ObsCoreLiveTableManager, ObsCoreSchema, + RegionTypeWarning, ) from lsst.daf.butler.registry.obscore._schema import _STATIC_COLUMNS from lsst.daf.butler.registry.sql_registry import SqlRegistry @@ -442,20 +442,17 @@ def test_associate(self): rows = list(result) self.assertEqual(len(rows), 0) - @unittest.skip("Temporary, while deprecation warnings are present.") def test_region_type_warning(self) -> None: """Test that non-polygon region generates one or more warnings.""" collections = None registry = self.make_registry(collections) - with warnings.catch_warnings(record=True) as warning_records: + with self.assertWarns(RegionTypeWarning) as cm: self._insert_dataset(registry, "run2", "calexp", detector=2, visit=9) - self.assertEqual(len(warning_records), 1) - for record in warning_records: - self.assertRegex( - str(record.message), - "Unexpected region type: .*lsst.sphgeom._sphgeom.Box.*", - ) + self.assertRegex( + str(cm.warning), + "Unexpected region type: .*lsst.sphgeom._sphgeom.Box.*", + ) def test_update_exposure_region(self) -> None: """Test for update_exposure_regions method."""