diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-09-27 14:47:57 +0800 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2017-09-27 14:47:57 +0800 |
commit | a39c3c06d51e17b20088a3b519bcd120250b3219 (patch) | |
tree | 1a9397d605eca180cf4f4ce7c33e53edcbf64978 | |
parent | 7ab8b570e758f9ef899b1041beafede489847ccb (diff) | |
download | psutil-a39c3c06d51e17b20088a3b519bcd120250b3219.tar.gz |
PEP8-ify code
-rw-r--r-- | psutil/_psaix.py | 1 | ||||
-rw-r--r-- | psutil/tests/test_aix.py | 54 | ||||
-rwxr-xr-x | psutil/tests/test_memory_leaks.py | 1 |
3 files changed, 23 insertions, 33 deletions
diff --git a/psutil/_psaix.py b/psutil/_psaix.py index 102e0f5f..2cbacacb 100644 --- a/psutil/_psaix.py +++ b/psutil/_psaix.py @@ -42,7 +42,6 @@ PAGE_SIZE = os.sysconf('SC_PAGE_SIZE') AF_LINK = cext_posix.AF_LINK PROC_STATUSES = { - cext.SIDL: _common.STATUS_IDLE, cext.SZOMB: _common.STATUS_ZOMBIE, cext.SACTIVE: _common.STATUS_RUNNING, diff --git a/psutil/tests/test_aix.py b/psutil/tests/test_aix.py index 281c9bb0..7a8a4c33 100644 --- a/psutil/tests/test_aix.py +++ b/psutil/tests/test_aix.py @@ -8,35 +8,27 @@ """AIX specific tests.""" -import os import re -import psutil from psutil import AIX -from psutil.tests import retry_before_failing from psutil.tests import run_test_module_by_name from psutil.tests import sh from psutil.tests import unittest +import psutil + @unittest.skipIf(not AIX, "AIX only") class AIXSpecificTestCase(unittest.TestCase): def test_virtual_memory(self): out = sh('/usr/bin/svmon -O unit=KB') - - # example output: - # Unit: KB - # -------------------------------------------------------------------------------------- - # size inuse free pin virtual available mmode - # memory 4194304 1844828 2349476 1250208 1412976 2621596 Ded - # pg space 524288 8304 re_pattern = "memory\s*" for field in ("size inuse free pin virtual available mmode").split(): re_pattern += "(?P<%s>\S+)\s+" % (field,) matchobj = re.search(re_pattern, out) - self.assertIsNotNone(matchobj, - "svmon command returned unexpected output") + self.assertIsNotNone( + matchobj, "svmon command returned unexpected output") KB = 1024 total = int(matchobj.group("size")) * KB @@ -51,20 +43,16 @@ class AIXSpecificTestCase(unittest.TestCase): # when compared to GBs. MEMORY_TOLERANCE = 2 * KB * KB # 2 MB self.assertEqual(psutil_result.total, total) - self.assertAlmostEqual(psutil_result.used, used, - delta=MEMORY_TOLERANCE) - self.assertAlmostEqual(psutil_result.available, available, - delta=MEMORY_TOLERANCE) - self.assertAlmostEqual(psutil_result.free, free, - delta=MEMORY_TOLERANCE) + self.assertAlmostEqual( + psutil_result.used, used, delta=MEMORY_TOLERANCE) + self.assertAlmostEqual( + psutil_result.available, available, delta=MEMORY_TOLERANCE) + self.assertAlmostEqual( + psutil_result.free, free, delta=MEMORY_TOLERANCE) def test_swap_memory(self): out = sh('/usr/sbin/lsps -a') - - # example output: - # Page Space Physical Volume Volume Group Size %Used Active Auto Type Chksum - # hd6 hdisk0 rootvg 512MB 2 yes yes lv 0 - # from the man page, "The size is given in megabytes" so we assume + # From the man page, "The size is given in megabytes" so we assume # we'll always have 'MB' in the result # TODO maybe try to use "swap -l" to check "used" too, but its units # are not guaranteed to be "MB" so parsing may not be consistent @@ -73,8 +61,8 @@ class AIXSpecificTestCase(unittest.TestCase): "(?P<vg>\S+)\s+" "(?P<size>\d+)MB", out) - self.assertIsNotNone(matchobj, - "lsps command returned unexpected output") + self.assertIsNotNone( + matchobj, "lsps command returned unexpected output") total_mb = int(matchobj.group("size")) MB = 1024 ** 2 @@ -93,22 +81,26 @@ class AIXSpecificTestCase(unittest.TestCase): re_pattern += "(?P<%s>\S+)\s+" % (field,) matchobj = re.search(re_pattern, out) - self.assertIsNotNone(matchobj, - "mpstat command returned unexpected output") + self.assertIsNotNone( + matchobj, "mpstat command returned unexpected output") # numbers are usually in the millions so 1000 is ok for tolerance CPU_STATS_TOLERANCE = 1000 psutil_result = psutil.cpu_stats() - self.assertAlmostEqual(psutil_result.ctx_switches, + self.assertAlmostEqual( + psutil_result.ctx_switches, int(matchobj.group("cs")), delta=CPU_STATS_TOLERANCE) - self.assertAlmostEqual(psutil_result.syscalls, + self.assertAlmostEqual( + psutil_result.syscalls, int(matchobj.group("sysc")), delta=CPU_STATS_TOLERANCE) - self.assertAlmostEqual(psutil_result.interrupts, + self.assertAlmostEqual( + psutil_result.interrupts, int(matchobj.group("dev")), delta=CPU_STATS_TOLERANCE) - self.assertAlmostEqual(psutil_result.soft_interrupts, + self.assertAlmostEqual( + psutil_result.soft_interrupts, int(matchobj.group("soft")), delta=CPU_STATS_TOLERANCE) diff --git a/psutil/tests/test_memory_leaks.py b/psutil/tests/test_memory_leaks.py index b7638d32..76fab357 100755 --- a/psutil/tests/test_memory_leaks.py +++ b/psutil/tests/test_memory_leaks.py @@ -24,7 +24,6 @@ import time import psutil import psutil._common -from psutil import AIX from psutil import LINUX from psutil import OPENBSD from psutil import OSX |