Coverage for python/lsst/ap/verify/testUtils.py: 54%
20 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 04:24 -0700
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 04:24 -0700
1#
2# This file is part of ap_verify.
3#
4# Developed for the LSST Data Management System.
5# This product includes software developed by the LSST Project
6# (http://www.lsst.org).
7# See the COPYRIGHT file at the top-level directory of this distribution
8# for details of code ownership.
9#
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program. If not, see <http://www.gnu.org/licenses/>.
22#
24"""Common code for ap_verify unit tests.
25"""
27__all__ = ["DataTestCase"]
29import unittest
31import lsst.utils.tests
34class DataTestCase(lsst.utils.tests.TestCase):
35 """Unit test class for tests that need to use the Dataset framework.
37 Unit tests based on this class will search for a designated dataset
38 (`testDataset`), and skip all tests if the dataset is not available.
40 Subclasses must call `DataTestCase.setUpClass()` if they override
41 ``setUpClass`` themselves.
42 """
44 testDataset = 'ap_verify_testdata'
45 """The EUPS package name of the dataset to use for testing (`str`).
46 """
47 obsPackage = 'obs_lsst'
48 """The obs package associated with ``testDataset`` (`str`).
50 Set to `None` if ``testDataset`` loads its own dependencies (not
51 recommended for test datasets).
52 """
54 @classmethod
55 def setUpClass(cls):
56 try:
57 lsst.utils.getPackageDir(cls.testDataset)
58 except LookupError:
59 raise unittest.SkipTest(f'{cls.testDataset} not set up')
60 if cls.obsPackage:
61 try:
62 lsst.utils.getPackageDir(cls.obsPackage)
63 except LookupError:
64 raise unittest.SkipTest(f'{cls.obsPackage} not set up; needed for {cls.testDataset}')