Coverage for tests/test_rewrite_qe.py: 42%

32 statements  

« prev     ^ index     » next       coverage.py v6.4.1, created at 2022-06-07 02:27 -0700

1# This file is part of obs_lsst. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://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 <http://www.gnu.org/licenses/>. 

21 

22"""Test the rewrite_ts8_qe_files.py script in bin.src.""" 

23 

24import unittest 

25import os 

26import shutil 

27import tempfile 

28import glob 

29 

30import lsst.utils 

31from lsst.meas.algorithms import Curve 

32from lsst.obs.lsst.script.rewrite_ts8_qe_files import rewrite_ts8_files 

33 

34TESTDIR = os.path.abspath(os.path.dirname(__file__)) 

35DATADIR = lsst.utils.getPackageDir('obs_lsst_data') 

36 

37 

38class RewriteQeTestCase(lsst.utils.tests.ExecutablesTestCase): 

39 """Test the rewrite_ts8_qe_files.py utility script.""" 

40 

41 def testRewriteQe(self): 

42 failed = False 

43 root = tempfile.mkdtemp(dir=TESTDIR) 

44 try: 

45 rewrite_ts8_files(os.path.join(TESTDIR, 'data/qe_test/RaftRun10517.p'), 

46 root, '1970-01-01T00:00:00') 

47 files = glob.glob(os.path.join(root, '*', '19700101T000000.ecsv')) 

48 self.assertEqual(len(files), 9) 

49 for f in files: 

50 curve1 = Curve.readText(f) 

51 expect_file = os.path.join(DATADIR, 'ts8', 'qe_curve', os.path.relpath(f, root)) 

52 curve2 = Curve.readText(expect_file) 

53 self.assertEqual(curve1, curve2) 

54 except Exception: 

55 failed = True 

56 raise 

57 finally: 

58 if failed: 

59 print(f"Output test data located in {root}") 

60 else: 

61 shutil.rmtree(root, ignore_errors=True) 

62 

63 

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

65 unittest.main()