From 1ebe625e5aa21b33e9de5652c305d1d0a2147059 Mon Sep 17 00:00:00 2001 From: wiggin15 Date: Tue, 26 Sep 2017 14:52:42 +0300 Subject: AIX support (#1123) * AIX support * AIX support * AIX support * AIX support - use get_procfs_path() instead of /proc * AIX support - group sections like in other modules * AIX support * AIX support * AIX support * AIX support - remove unnecessary dict copy --- psutil/tests/test_contracts.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'psutil/tests/test_contracts.py') diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index 65bad757..13a737e8 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -16,6 +16,7 @@ import time import traceback from contextlib import closing +from psutil import AIX from psutil import BSD from psutil import FREEBSD from psutil import LINUX @@ -65,7 +66,8 @@ class TestAvailability(unittest.TestCase): self.assertEqual(hasattr(psutil, "win_service_get"), WINDOWS) def test_PROCFS_PATH(self): - self.assertEqual(hasattr(psutil, "PROCFS_PATH"), LINUX or SUNOS) + self.assertEqual(hasattr(psutil, "PROCFS_PATH"), + LINUX or SUNOS or AIX) def test_win_priority(self): ae = self.assertEqual @@ -159,7 +161,7 @@ class TestAvailability(unittest.TestCase): def test_proc_memory_maps(self): hasit = hasattr(psutil.Process, "memory_maps") - self.assertEqual(hasit, False if OPENBSD or NETBSD else True) + self.assertEqual(hasit, False if OPENBSD or NETBSD or AIX else True) # =================================================================== @@ -372,12 +374,14 @@ class TestFetchAllProcesses(unittest.TestCase): self.assertGreaterEqual(ret, 0) def ppid(self, ret, proc): - self.assertIsInstance(ret, int) + self.assertIsInstance(ret, (int, long)) self.assertGreaterEqual(ret, 0) def name(self, ret, proc): self.assertIsInstance(ret, str) - assert ret + # on AIX, "" processes don't have names + if not AIX: + assert ret def create_time(self, ret, proc): self.assertIsInstance(ret, float) @@ -482,7 +486,7 @@ class TestFetchAllProcesses(unittest.TestCase): for value in ret: self.assertIsInstance(value, (int, long)) self.assertGreaterEqual(value, 0) - if POSIX and ret.vms != 0: + if POSIX and not AIX and ret.vms != 0: # VMS is always supposed to be the highest for name in ret._fields: if name != 'vms': @@ -536,8 +540,8 @@ class TestFetchAllProcesses(unittest.TestCase): check_connection_ntuple(conn) def cwd(self, ret, proc): - self.assertIsInstance(ret, str) - if ret is not None: # BSD may return None + if ret: # 'ret' can be None or empty + self.assertIsInstance(ret, str) assert os.path.isabs(ret), ret try: st = os.stat(ret) -- cgit v1.2.1 From 65a52341b55faaab41f68ebc4ed31f18f0929754 Mon Sep 17 00:00:00 2001 From: wiggin15 Date: Tue, 31 Oct 2017 11:46:08 +0200 Subject: AIX: implement num_ctx_switches (#1164) * small changes * AIX: implement num_ctx_switches --- psutil/tests/test_contracts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'psutil/tests/test_contracts.py') diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index 13a737e8..d9633339 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -611,7 +611,7 @@ class TestFetchAllProcesses(unittest.TestCase): def num_ctx_switches(self, ret, proc): assert is_namedtuple(ret) for value in ret: - self.assertIsInstance(value, int) + self.assertIsInstance(value, (int, long)) self.assertGreaterEqual(value, 0) def rlimit(self, ret, proc): -- cgit v1.2.1 From 02e25d765040d3f36ecc66249700a8777b175c7a Mon Sep 17 00:00:00 2001 From: wiggin15 Date: Sat, 11 Nov 2017 03:34:22 +0200 Subject: skip cpu_freq tests if not available (#1170) cpu_freq is not always available on Linux --- psutil/tests/test_contracts.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'psutil/tests/test_contracts.py') diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index d9633339..5e5c2e9a 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -110,7 +110,10 @@ class TestAvailability(unittest.TestCase): ae(hasattr(psutil, "RLIMIT_SIGPENDING"), hasit) def test_cpu_freq(self): - self.assertEqual(hasattr(psutil, "cpu_freq"), LINUX or OSX or WINDOWS) + linux = (LINUX and + (os.path.exists("/sys/devices/system/cpu/cpufreq") or + os.path.exists("/sys/devices/system/cpu/cpu0/cpufreq"))) + self.assertEqual(hasattr(psutil, "cpu_freq"), linux or OSX or WINDOWS) def test_sensors_temperatures(self): self.assertEqual(hasattr(psutil, "sensors_temperatures"), LINUX) -- cgit v1.2.1 From 3a3598e433adec73e2a9c4d5f08e658516fb1d32 Mon Sep 17 00:00:00 2001 From: wiggin15 Date: Sun, 19 Nov 2017 20:06:18 +0200 Subject: OSX: implement sensors_battery (#1177) --- psutil/tests/test_contracts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'psutil/tests/test_contracts.py') diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index 5e5c2e9a..4c57b25a 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -123,7 +123,7 @@ class TestAvailability(unittest.TestCase): def test_battery(self): self.assertEqual(hasattr(psutil, "sensors_battery"), - LINUX or WINDOWS or FREEBSD) + LINUX or WINDOWS or FREEBSD or OSX) def test_proc_environ(self): self.assertEqual(hasattr(psutil.Process, "environ"), -- cgit v1.2.1 From c3767da76a366cabbe1c84ad9cef007ae51c400e Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Thu, 7 Dec 2017 11:02:35 +0100 Subject: Use FutureWarning instead of DeprecationWarning (#1188) * make Process.memory_info_ex() raise FutureWarning instead of DeprecationWarning because the latter is suppressed by default * update HISTORY * add test case --- psutil/tests/test_contracts.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'psutil/tests/test_contracts.py') diff --git a/psutil/tests/test_contracts.py b/psutil/tests/test_contracts.py index 4c57b25a..855b53bf 100755 --- a/psutil/tests/test_contracts.py +++ b/psutil/tests/test_contracts.py @@ -14,6 +14,7 @@ import os import stat import time import traceback +import warnings from contextlib import closing from psutil import AIX @@ -167,6 +168,22 @@ class TestAvailability(unittest.TestCase): self.assertEqual(hasit, False if OPENBSD or NETBSD or AIX else True) +# =================================================================== +# --- Test deprecations +# =================================================================== + + +class TestDeprecations(unittest.TestCase): + + def test_memory_info_ex(self): + with warnings.catch_warnings(record=True) as ws: + psutil.Process().memory_info_ex() + w = ws[0] + self.assertIsInstance(w.category(), FutureWarning) + self.assertIn("memory_info_ex() is deprecated", str(w.message)) + self.assertIn("use memory_info() instead", str(w.message)) + + # =================================================================== # --- System API types # =================================================================== -- cgit v1.2.1