Coverage for tests/test_LogicalLocation.py: 44%
33 statements
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-11 02:48 -0700
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-11 02:48 -0700
1#
2# LSST Data Management System
3# Copyright 2008, 2009, 2010 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#
24import unittest
26from lsst.daf.persistence import LogicalLocation
27from lsst.daf.base import PropertySet
29import lsst.utils.tests
30import lsst.log
31lsst.log.setLevel("daf.persistence.LogicalLocation", lsst.log.TRACE)
34class LogicalLocationTestCase(unittest.TestCase):
35 """A test case for LogicalLocation."""
37 def testSubst(self):
38 ad = PropertySet()
39 ad.set("foo", "bar")
40 ad.setInt("x", 3)
41 LogicalLocation.setLocationMap(ad)
42 loc = LogicalLocation("%(foo)xx")
43 self.assertEqual(loc.locString(), "barxx")
44 loc = LogicalLocation("%(x)foo")
45 self.assertEqual(loc.locString(), "3foo")
46 loc = LogicalLocation("yy%04d(x)yy")
47 self.assertEqual(loc.locString(), "yy0003yy")
49 ad2 = PropertySet()
50 ad2.set("foo", "baz")
51 ad2.setInt("y", 2009)
52 loc = LogicalLocation("%(foo)%(x)%(y)", ad2)
53 self.assertEqual(loc.locString(), "bar32009")
54 LogicalLocation.setLocationMap(PropertySet())
55 loc = LogicalLocation("%(foo)%3d(y)", ad2)
56 self.assertEqual(loc.locString(), "baz2009")
59class TestMemory(lsst.utils.tests.MemoryTestCase):
60 pass
63def setup_module(module):
64 lsst.utils.tests.init()
67if __name__ == "__main__": 67 ↛ 68line 67 didn't jump to line 68, because the condition on line 67 was never true
68 lsst.utils.tests.init()
69 unittest.main()