Coverage for tests/test_usage.py: 38%
16 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-08 09:53 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-08 09:53 +0000
1# This file is part of utils.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# Use of this source code is governed by a 3-clause BSD-style
10# license that can be found in the LICENSE file.
12import unittest
14from astropy import units as u
15from lsst.utils.usage import get_current_mem_usage, get_peak_mem_usage
18class UsageTestCase(unittest.TestCase):
19 """Test resource usage functions."""
21 def testGetCurrentMemUsage(self):
22 main, children = get_current_mem_usage()
23 self.assertGreater(main, 0 * u.byte)
24 self.assertGreaterEqual(children, 0 * u.byte)
26 self.assertTrue(main.unit.is_equivalent(u.byte))
27 self.assertTrue(children.unit.is_equivalent(u.byte))
29 def testGetPeakMemUsage(self):
30 main, child = get_peak_mem_usage()
31 self.assertGreater(main, 0 * u.byte)
32 self.assertGreaterEqual(child, 0 * u.byte)
34 self.assertTrue(main.unit.is_equivalent(u.byte))
35 self.assertTrue(child.unit.is_equivalent(u.byte))
38if __name__ == "__main__":
39 unittest.main()