Coverage for tests/test_schema.py: 50%

30 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-01-21 02:13 -0800

1# 

2# LSST Data Management System 

3# 

4# Copyright 2018 AURA/LSST. 

5# 

6# This product includes software developed by the 

7# LSST Project (http://www.lsst.org/). 

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 LSST License Statement and 

20# the GNU General Public License along with this program. If not, 

21# see <https://www.lsstcorp.org/LegalNotices/>. 

22# 

23import os 

24import unittest 

25 

26import lsst.utils.tests 

27import lsst.afw.image as afwImage 

28import lsst.afw.table as afwTable 

29from lsst.meas.algorithms.detection import SourceDetectionTask 

30from lsst.meas.deblender import SourceDeblendTask 

31 

32DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "data") 

33 

34 

35class SchemaTestCase(lsst.utils.tests.TestCase): 

36 

37 def setUp(self): 

38 self.calexp = afwImage.ExposureF(os.path.join(DATA_DIR, "ticket1738.fits")) 

39 

40 def tearDown(self): 

41 del self.calexp 

42 

43 def testMismatchedSchema(self): 

44 schema = afwTable.SourceTable.makeMinimalSchema() 

45 

46 # Create the detection task and process the data 

47 detectionTask = SourceDetectionTask(schema=schema) 

48 table = afwTable.SourceTable.make(schema) 

49 result = detectionTask.run(table, self.calexp) 

50 self.assertEqual(schema, result.sources.getSchema()) 

51 

52 # SourceDeblendTask modifies the schema in-place at construction 

53 # and add extra keys to it 

54 deblendTask = SourceDeblendTask(schema) 

55 self.assertNotEqual(schema, result.sources.getSchema()) 

56 

57 # As the deblendTask has a different schema than the original schema 

58 # of the detectionTask, the assert should fail and stop running 

59 with self.assertRaises(AssertionError): 

60 deblendTask.run(self.calexp, result.sources) 

61 

62 

63class TestMemory(lsst.utils.tests.MemoryTestCase): 

64 pass 

65 

66 

67def setup_module(module): 

68 lsst.utils.tests.init() 

69 

70 

71if __name__ == "__main__": 71 ↛ 72line 71 didn't jump to line 72, because the condition on line 71 was never true

72 lsst.utils.tests.init() 

73 unittest.main()