diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-10-17 03:45:30 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-10-17 03:45:30 +0200 |
commit | 59ba7a57144e22cd0b728b6aad564afaa50440f6 (patch) | |
tree | 772a736cac25033a5c81e497c657ee4da0b8c9f6 | |
parent | 239ebc19c8477893870e497fd344744cb5d964a7 (diff) | |
download | psutil-59ba7a57144e22cd0b728b6aad564afaa50440f6.tar.gz |
increase test coverage
-rw-r--r-- | psutil/__init__.py | 4 | ||||
-rw-r--r-- | psutil/_common.py | 3 | ||||
-rw-r--r-- | psutil/_pslinux.py | 2 | ||||
-rw-r--r-- | psutil/_psposix.py | 4 | ||||
-rwxr-xr-x | psutil/tests/test_system.py | 2 |
5 files changed, 9 insertions, 6 deletions
diff --git a/psutil/__init__.py b/psutil/__init__.py index 9d43f991..2108a40e 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -264,7 +264,7 @@ if (int(__version__.replace('.', '')) != if hasattr(_psplatform, 'ppid_map'): # Faster version (Windows and Linux). _ppid_map = _psplatform.ppid_map -else: +else: # pragma: no cover def _ppid_map(): """Return a {pid: ppid, ...} dict for all running processes in one shot. Used to speed up Process.children(). @@ -393,7 +393,7 @@ class Process(object): def __str__(self): try: info = collections.OrderedDict() - except AttributeError: + except AttributeError: # pragma: no cover info = {} # Python 2.6 info["pid"] = self.pid if self._name: diff --git a/psutil/_common.py b/psutil/_common.py index 74366456..0ddb5f9c 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -799,7 +799,8 @@ def hilite(s, color=None, bold=False): return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), s) -def print_color(s, color=None, bold=False, file=sys.stdout): +def print_color( + s, color=None, bold=False, file=sys.stdout): # pragma: no cover """Print a colorized version of string.""" if not term_supports_colors(): print(s, file=file) # NOQA diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 3c9ff281..382a17fa 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -307,7 +307,7 @@ def cat(fname, fallback=_DEFAULT, binary=True): try: set_scputimes_ntuple("/proc") -except Exception: +except Exception: # pragma: no cover # Don't want to crash at import time. traceback.print_exc() scputimes = namedtuple('scputimes', 'user system idle')(0.0, 0.0, 0.0) diff --git a/psutil/_psposix.py b/psutil/_psposix.py index 2e6711a3..706dab9a 100644 --- a/psutil/_psposix.py +++ b/psutil/_psposix.py @@ -65,7 +65,7 @@ if enum is not None and hasattr(signal, "Signals"): return Negsignal(num) except ValueError: return num -else: +else: # pragma: no cover def negsig_to_enum(num): return num @@ -167,7 +167,7 @@ def disk_usage(path): """ if PY3: st = os.statvfs(path) - else: + else: # pragma: no cover # os.statvfs() does not support unicode on Python 2: # - https://github.com/giampaolo/psutil/issues/416 # - http://bugs.python.org/issue18695 diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py index e368ea76..787397ad 100755 --- a/psutil/tests/test_system.py +++ b/psutil/tests/test_system.py @@ -483,6 +483,8 @@ class TestCpuAPIs(PsutilTestCase): self._test_cpu_percent(percent, last, new) self._test_cpu_percent(sum(new), last, new) last = new + with self.assertRaises(ValueError): + psutil.cpu_times_percent(interval=-1) def test_per_cpu_times_percent(self): last = psutil.cpu_times_percent(interval=0.001, percpu=True) |