comparison planemo/lib/python3.7/site-packages/psutil/tests/test_sunos.py @ 1:56ad4e20f292 draft

"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author guerler
date Fri, 31 Jul 2020 00:32:28 -0400
parents
children
comparison
equal deleted inserted replaced
0:d30785e31577 1:56ad4e20f292
1 #!/usr/bin/env python3
2
3 # Copyright (c) 2009, Giampaolo Rodola'. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 """Sun OS specific tests."""
8
9 import os
10
11 import psutil
12 from psutil import SUNOS
13 from psutil.tests import PsutilTestCase
14 from psutil.tests import sh
15 from psutil.tests import unittest
16
17
18 @unittest.skipIf(not SUNOS, "SUNOS only")
19 class SunOSSpecificTestCase(PsutilTestCase):
20
21 def test_swap_memory(self):
22 out = sh('env PATH=/usr/sbin:/sbin:%s swap -l' % os.environ['PATH'])
23 lines = out.strip().split('\n')[1:]
24 if not lines:
25 raise ValueError('no swap device(s) configured')
26 total = free = 0
27 for line in lines:
28 line = line.split()
29 t, f = line[-2:]
30 total += int(int(t) * 512)
31 free += int(int(f) * 512)
32 used = total - free
33
34 psutil_swap = psutil.swap_memory()
35 self.assertEqual(psutil_swap.total, total)
36 self.assertEqual(psutil_swap.used, used)
37 self.assertEqual(psutil_swap.free, free)
38
39 def test_cpu_count(self):
40 out = sh("/usr/sbin/psrinfo")
41 self.assertEqual(psutil.cpu_count(), len(out.split('\n')))
42
43
44 if __name__ == '__main__':
45 from psutil.tests.runner import run_from_name
46 run_from_name(__file__)