Coverage for tests/test_logging.py: 28%
Shortcuts 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
Shortcuts 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# This file is part of pipe_base.
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/>.
22"""Simple unit test for Task logging.
23"""
25import logging
26import unittest
28from lsst.pipe.base import getTaskLogger
31class TestLogging(unittest.TestCase):
33 def testLogLevels(self):
34 """Check that the new log levels look reasonable."""
36 root = getTaskLogger()
38 self.assertEqual(root.DEBUG, logging.DEBUG)
39 self.assertGreater(root.VERBOSE, logging.DEBUG)
40 self.assertLess(root.VERBOSE, logging.INFO)
41 self.assertLess(root.TRACE, logging.DEBUG)
43 def testLogCommands(self):
44 """Check that all the log commands work."""
46 root = getTaskLogger()
48 with self.assertLogs(level=root.TRACE) as cm:
49 root.trace("Trace")
50 root.debug("Debug")
51 root.verbose("Verbose")
52 root.info("Info")
53 root.warning("Warning")
54 root.fatal("Fatal")
55 root.critical("Critical")
56 root.error("Error")
58 self.assertEqual(len(cm.records), 8)
60 # Check that each record has an explicit level name rather than
61 # "Level N" and comes from this file (and not the task_logging.py).
62 for record in cm.records:
63 self.assertRegex(record.levelname, "^[A-Z]+$")
64 self.assertEqual(record.filename, "test_logging.py")
67if __name__ == "__main__": 67 ↛ 68line 67 didn't jump to line 68, because the condition on line 67 was never true
68 unittest.main()