Coverage for tests/test_decorators.py : 49%

Hot-keys 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#
2# Developed for the LSST Data Management System.
3# This product includes software developed by the LSST Project
4# (https://www.lsst.org).
5# See the COPYRIGHT file at the top-level directory of this distribution
6# for details of code ownership.
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 GNU General Public License
19# along with this program. If not, see <https://www.gnu.org/licenses/>.
20#
22import sys
23import unittest
25import lsst.utils.tests
28numCalls = 0 # Number of times testMethodDecorator gets called
31@lsst.utils.tests.classParameters(
32 word=["one", "two", "three", "four"],
33 length=[3, 3, 5, 4]
34)
35class DecoratorTestCase(lsst.utils.tests.TestCase):
36 def setUp(self):
37 self.numCalls = 0
39 def testClassDecorator(self):
40 self.assertEqual(len(self.word), self.length)
41 self.assertEqual(self.__class__.__name__, f"DecoratorTestCase_{self.word}_{self.length}")
43 @lsst.utils.tests.methodParameters(
44 xx=[1, 2, 3],
45 yy=[9, 8, 7],
46 )
47 def testMethodDecorator(self, xx, yy):
48 self.assertEqual(xx + yy, 10)
49 self.numCalls += 1
51 def teardown_method(self, method):
52 if method.__name__ == "testMethodDecorator":
53 self.assertEqual(self.numCalls, 3)
56def testDecorators():
57 world = globals()
58 assert "DecoratorTestCase_one_3" in world
59 assert "DecoratorTestCase_two_3" in world
60 assert "DecoratorTestCase_three_5" in world
61 assert "DecoratorTestCase_four_4" in world
64class TestMemory(lsst.utils.tests.MemoryTestCase):
65 pass
68def setup_module(module):
69 lsst.utils.tests.init()
72if __name__ == "__main__": 72 ↛ 73line 72 didn't jump to line 73, because the condition on line 72 was never true
73 module = sys.modules[__name__]
74 setup_module(module)
75 testDecorators()
76 unittest.main()