Coverage for tests/test_metricRegistry.py: 38%
40 statements
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-15 02:14 -0700
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-15 02:14 -0700
1# This file is part of verify.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22import unittest
24import lsst.utils.tests
26from lsst.verify.gen2tasks import register, registerMultiple
27from lsst.verify.gen2tasks.metricRegistry import MetricRegistry
28from lsst.verify.tasks import MetricTask
31class MetricRegistryTestSuite(lsst.utils.tests.TestCase):
32 @classmethod
33 def setUpClass(cls):
34 # Remember the implementation class of the registry for later use
35 cls.RegistryClass = type(MetricRegistry.registry)
37 def setUp(self):
38 # Clear out old registry by replacing it
39 MetricRegistry.registry = self.RegistryClass()
41 def testRegistration(self):
42 @register("foo")
43 class DummyMetricTask(MetricTask):
44 pass
46 self.assertIn("foo", MetricRegistry.registry)
47 self.assertEqual(MetricRegistry.registry["foo"], DummyMetricTask)
49 def testMultiRegistration(self):
50 @registerMultiple("foo")
51 class DummyMetricTask(MetricTask):
52 pass
54 self.assertIn("foo", MetricRegistry.registry)
55 # Type of registry entry is implementation detail; functionality better
56 # tested in test_metricsController
58 def testInvalidRegistration(self):
59 with self.assertRaises(ValueError):
60 @register("bar")
61 class NotAMetricTask:
62 pass
64 def testInvalidMultiRegistration(self):
65 with self.assertRaises(RuntimeError):
66 @register("foo")
67 @registerMultiple("foo")
68 class DummyMetricTask(MetricTask):
69 pass
72class MemoryTester(lsst.utils.tests.MemoryTestCase):
73 pass
76def setup_module(module):
77 lsst.utils.tests.init()
80if __name__ == "__main__": 80 ↛ 81line 80 didn't jump to line 81, because the condition on line 80 was never true
81 lsst.utils.tests.init()
82 unittest.main()