Coverage for tests/test_usage.py: 38%

16 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-25 09:27 +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. 

11 

12import unittest 

13 

14from astropy import units as u 

15from lsst.utils.usage import get_current_mem_usage, get_peak_mem_usage 

16 

17 

18class UsageTestCase(unittest.TestCase): 

19 """Test resource usage functions.""" 

20 

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) 

25 

26 self.assertTrue(main.unit.is_equivalent(u.byte)) 

27 self.assertTrue(children.unit.is_equivalent(u.byte)) 

28 

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) 

33 

34 self.assertTrue(main.unit.is_equivalent(u.byte)) 

35 self.assertTrue(child.unit.is_equivalent(u.byte)) 

36 

37 

38if __name__ == "__main__": 

39 unittest.main()