Coverage for tests/test_weather.py : 30%

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# LSST Data Management System
3# Copyright 2016 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#
22"""
23Tests for lsst.afw.image.Weather
24"""
25import unittest
27import lsst.utils.tests
28import lsst.pex.exceptions
29from lsst.afw.coord import Weather
32class WeatherTestCase(unittest.TestCase):
33 """Test lsst.afw.coord.Weather, a simple struct-like class"""
35 def testBasics(self):
36 prevWeather = None
37 for temp, pressure in ((1.1, 2.2), (100.1, 200.2)): # arbitrary values
38 # 0 and greater, including supersaturation
39 for humidity in (0.0, 10.1, 100.0, 120.5):
40 weather = Weather(temp, pressure, humidity)
41 self.assertEqual(weather.getAirTemperature(), temp)
42 self.assertEqual(weather.getAirPressure(), pressure)
43 self.assertEqual(weather.getHumidity(), humidity)
45 # test copy constructor
46 weatherCopy = Weather(weather)
47 self.assertEqual(weatherCopy.getAirTemperature(), temp)
48 self.assertEqual(weatherCopy.getAirPressure(), pressure)
49 self.assertEqual(weatherCopy.getHumidity(), humidity)
51 # test == (using a copy, to make sure the test is not based on
52 # identity) and !=
53 self.assertEqual(weather, weatherCopy)
54 if prevWeather is not None:
55 self.assertNotEqual(weather, prevWeather)
56 prevWeather = weather
58 def testBadHumidity(self):
59 """Check bad humidity handling (humidity is the only value whose range is checked)"""
60 for humidity in (-1, -0.0001):
61 with self.assertRaises(lsst.pex.exceptions.InvalidParameterError):
62 Weather(1.1, 2.2, humidity)
65def setup_module(module):
66 lsst.utils.tests.init()
69class MemoryTester(lsst.utils.tests.MemoryTestCase):
70 pass
73if __name__ == "__main__": 73 ↛ 74line 73 didn't jump to line 74, because the condition on line 73 was never true
74 lsst.utils.tests.init()
75 unittest.main()