Coverage for tests/test_cliLog.py: 59%
20 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-01 10:04 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-01 10:04 +0000
1# This file is part of daf_butler.
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"""Unit tests for the daf_butler dataset-type CLI option.
23"""
25import logging
26import unittest
28from lsst.daf.butler.cli.cliLog import CliLog
29from lsst.daf.butler.tests import CliLogTestBase
31try:
32 import lsst.log as lsstLog
33except ModuleNotFoundError:
34 lsstLog = None
37class CliLogTestCase(CliLogTestBase, unittest.TestCase):
38 """Test log initialization, reset, and setting log levels on python
39 `logging` and also `lsst.log` if it is setup.
41 This will not test use of `lsst.log` in CI because daf_butler does not
42 directly depend on that package. When running in an environment where
43 `lsst.log` is setup then this will test use of `lsst.log`. This test also
44 runs in obs_base which does provide coverage of python `logging` and
45 `lsst.log` in CI."""
47 pass
50class ConvertPyLogLevelTestCase(unittest.TestCase):
51 def test_convertToPyLogLevel(self):
52 self.assertEqual(logging.CRITICAL, CliLog._getPyLogLevel("CRITICAL"))
53 self.assertEqual(logging.ERROR, CliLog._getPyLogLevel("ERROR"))
54 self.assertEqual(logging.WARN, CliLog._getPyLogLevel("WARNING"))
55 self.assertEqual(logging.INFO, CliLog._getPyLogLevel("INFO"))
56 self.assertEqual(logging.DEBUG, CliLog._getPyLogLevel("DEBUG"))
59if __name__ == "__main__": 59 ↛ 60line 59 didn't jump to line 60, because the condition on line 59 was never true
60 unittest.main()