Coverage for tests/test_fakes.py : 91%

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# LSST Data Management System
3# Copyright 2008-2013 LSST Corporation.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <http://www.lsstcorp.org/LegalNotices/>.
21#
23import unittest
25import lsst.utils
26import lsst.afw.image
27import lsst.utils.tests
28import lsst.pipe.tasks.fakes as fakes
31class TrialFakeSourcesConfig(fakes.BaseFakeSourcesConfig):
32 pass
35class TrialFakeSourcesTask(fakes.BaseFakeSourcesTask):
36 ConfigClass = TrialFakeSourcesConfig
38 def __init__(self, **kwargs):
39 fakes.BaseFakeSourcesTask.__init__(self, **kwargs)
41 def run(self, exposure, background):
42 pass
45class TestFakes(lsst.utils.tests.TestCase):
47 def testFakeMaskAdded(self):
48 '''
49 Test that the FAKE mask plane does not exist, that it is added, and the instance's
50 bitmask points to the correct plane
51 '''
52 maskPlaneName = "FAKE"
53 maskKeysBefore = list(lsst.afw.image.Mask().getMaskPlaneDict())
54 trialInstance = TrialFakeSourcesTask()
55 maskKeysAfter = list(lsst.afw.image.Mask().getMaskPlaneDict())
56 maskPlaneName = trialInstance.config.maskPlaneName
57 self.assertNotIn(maskPlaneName, maskKeysBefore)
58 self.assertIn(maskPlaneName, maskKeysAfter)
59 self.assertEqual(trialInstance.bitmask, lsst.afw.image.Mask[lsst.afw.image.MaskPixel]
60 .getPlaneBitMask(maskPlaneName))
61 lsst.afw.image.Mask[lsst.afw.image.MaskPixel].removeMaskPlane(maskPlaneName)
62 del trialInstance
64 def testFakeMasked(self):
65 '''
66 Test that if the FAKE mask plane exists, it is used, and that the instance's bitmask
67 points to the correct plane
68 '''
69 maskPlaneName = "FAKE"
70 lsst.afw.image.Mask[lsst.afw.image.MaskPixel].addMaskPlane(maskPlaneName)
71 maskKeysBefore = list(lsst.afw.image.Mask().getMaskPlaneDict())
72 self.assertIn(maskPlaneName, maskKeysBefore)
73 maskPlaneBitMask = lsst.afw.image.Mask[lsst.afw.image.MaskPixel].getPlaneBitMask(maskPlaneName)
74 trialInstance = TrialFakeSourcesTask()
75 self.assertEqual(maskPlaneBitMask, trialInstance.bitmask)
76 lsst.afw.image.Mask[lsst.afw.image.MaskPixel].removeMaskPlane(maskPlaneName)
77 del trialInstance
80def setup_module(module):
81 lsst.utils.tests.init()
84class MatchMemoryTestCase(lsst.utils.tests.MemoryTestCase):
85 pass
88if __name__ == "__main__": 88 ↛ 89line 88 didn't jump to line 89, because the condition on line 88 was never true
89 lsst.utils.tests.init()
90 unittest.main()