Coverage for python/lsst/ap/verify/testUtils.py : 64%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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"""
27import unittest
29import lsst.utils.tests
31import lsst.pex.exceptions as pexExcept
32from lsst.ap.verify.config import Config
35class DataTestCase(lsst.utils.tests.TestCase):
36 """Unit test class for tests that need to use the Dataset framework.
38 Unit tests based on this class will search for a designated dataset
39 (`testDataset`), and skip all tests if the dataset is not available.
41 Subclasses must call `DataTestCase.setUpClass()` if they override
42 ``setUpClass`` themselves.
43 """
45 testDataset = 'ap_verify_testdata'
46 """The EUPS package name of the dataset to use for testing (`str`).
47 """
48 datasetKey = 'test'
49 """The ap_verify dataset name that would be used on the command line (`str`).
50 """
52 @classmethod
53 def setUpClass(cls):
54 try:
55 lsst.utils.getPackageDir(cls.testDataset)
56 except pexExcept.NotFoundError:
57 raise unittest.SkipTest(cls.testDataset + ' not set up')
59 # Hack the config for testing purposes
60 # Note that Config.instance is supposed to be immutable, so, depending on initialization order,
61 # this modification may cause other tests to see inconsistent config values
62 Config.instance._allInfo['datasets.' + cls.datasetKey] = cls.testDataset