From 3f67688df6c47eec3427c001ef1f11b14e6fcaf2 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Fri, 5 Apr 2019 16:26:07 +0200 Subject: fix linux tests --- psutil/__init__.py | 2 +- psutil/_pslinux.py | 4 ++-- psutil/tests/test_process.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/psutil/__init__.py b/psutil/__init__.py index a217a9e7..90066f39 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -2489,7 +2489,7 @@ def test(): # pragma: no cover p.info['memory_info'] is not None else '' rss = bytes2human(p.info['memory_info'].rss) if \ p.info['memory_info'] is not None else '' - memp = round(p.info['memory_percent']) if \ + memp = round(p.info['memory_percent'], 1) if \ p.info['memory_percent'] is not None else '' print(templ % ( diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 6c58cf2c..bf815e87 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1988,8 +1988,8 @@ class Process(object): def ionice_set(self, ioclass, value): if value is None: value = 0 - if value and ioclass == IOPRIO_CLASS_IDLE: - raise ValueError("IOPRIO_CLASS_IDLE accepts no value") + if value and ioclass in (IOPRIO_CLASS_IDLE, IOPRIO_CLASS_NONE): + raise ValueError("%r ioclass accepts no value" % ioclass) if value < 0 or value > 7: raise ValueError("value not in 0-7 range") return cext.proc_ioprio_set(self.pid, ioclass, value) diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index 25c70a25..a4b738ee 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -382,10 +382,10 @@ class TestProcess(unittest.TestCase): p.ionice(psutil.IOPRIO_CLASS_IDLE, value=8) # errs self.assertRaisesRegex( - ValueError, "can't specify value with IOPRIO_CLASS_NONE", + ValueError, "ioclass accepts no value", p.ionice, psutil.IOPRIO_CLASS_NONE, 1) self.assertRaisesRegex( - ValueError, "can't specify value with IOPRIO_CLASS_IDLE", + ValueError, "ioclass accepts no value", p.ionice, psutil.IOPRIO_CLASS_IDLE, 1) self.assertRaisesRegex( ValueError, "'ioclass' argument must be specified", -- cgit v1.2.1