summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2016-02-18 15:05:42 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2016-02-18 15:05:42 +0100
commite7309891bbe03d7a2950021e2e290af8d86bd021 (patch)
tree37b2d9ab4a2fc5223e912433dc27c8d80fbbb4f8
parentf4734c80203023458cb05b1499db611ed4916af2 (diff)
downloadpsutil-e7309891bbe03d7a2950021e2e290af8d86bd021.tar.gz
imorove test coverage
-rw-r--r--psutil/_common.py2
-rw-r--r--psutil/tests/test_process.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/psutil/_common.py b/psutil/_common.py
index 13e6a828..c90b0ba5 100644
--- a/psutil/_common.py
+++ b/psutil/_common.py
@@ -92,7 +92,7 @@ def usage_percent(used, total, _round=None):
try:
ret = (used / total) * 100
except ZeroDivisionError:
- ret = 0
+ ret = 0.0 if isinstance(used, float) or isinstance(total, float) else 0
if _round is not None:
return round(ret, _round)
else:
diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py
index ecf99723..0fc27940 100644
--- a/psutil/tests/test_process.py
+++ b/psutil/tests/test_process.py
@@ -154,6 +154,12 @@ class TestProcess(unittest.TestCase):
with self.assertRaises(psutil.AccessDenied):
psutil.Process().send_signal(sig)
assert fun.called
+ # Sending a signal to process with PID 0 is not allowed as
+ # it would affect every process in the process group of
+ # the calling process (os.getpid()) instead of PID 0").
+ if 0 in psutil.pids():
+ p = psutil.Process(0)
+ self.assertRaises(ValueError, p.send_signal, signal.SIGTERM)
def test_wait(self):
# check exit code signal