python-psutil/python-psutil-skip-tests-in-mock.patch

167 lines
6.8 KiB
Diff
Raw Normal View History

2024-02-09 13:32:48 +00:00
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index 0aa04f1..1096d3c 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -272,7 +272,7 @@ class TestSystemVirtualMemoryAgainstFree(PsutilTestCase):
2023-08-04 11:45:17 +00:00
psutil_value = psutil.virtual_memory().total
self.assertEqual(cli_value, psutil_value)
2023-07-11 05:41:06 +00:00
- @retry_on_failure()
+ @unittest.skip("Unreliable on mock")
def test_used(self):
# Older versions of procps used slab memory to calculate used memory.
# This got changed in:
2024-02-09 13:32:48 +00:00
@@ -337,6 +337,7 @@ class TestSystemVirtualMemoryAgainstVmstat(PsutilTestCase):
)
2023-08-04 11:45:17 +00:00
@retry_on_failure()
+ @unittest.skip("Unreliable in mock")
def test_used(self):
# Older versions of procps used slab memory to calculate used memory.
# This got changed in:
2024-02-09 13:32:48 +00:00
@@ -717,10 +718,7 @@ class TestSystemCPUTimes(PsutilTestCase):
2023-08-04 11:45:17 +00:00
@unittest.skipIf(not LINUX, "LINUX only")
class TestSystemCPUCountLogical(PsutilTestCase):
2024-02-09 13:32:48 +00:00
- @unittest.skipIf(
- not os.path.exists("/sys/devices/system/cpu/online"),
- "/sys/devices/system/cpu/online does not exist",
- )
+ @unittest.skip("Unreliable on mock")
2023-08-04 11:45:17 +00:00
def test_against_sysdev_cpu_online(self):
with open("/sys/devices/system/cpu/online") as f:
value = f.read().strip()
2024-02-09 13:32:48 +00:00
@@ -728,16 +726,13 @@ class TestSystemCPUCountLogical(PsutilTestCase):
2023-08-04 13:32:52 +00:00
value = int(value.split('-')[1]) + 1
self.assertEqual(psutil.cpu_count(), value)
2024-02-09 13:32:48 +00:00
- @unittest.skipIf(
- not os.path.exists("/sys/devices/system/cpu"),
- "/sys/devices/system/cpu does not exist",
- )
+ @unittest.skip("Unreliable on mock")
2023-08-04 13:32:52 +00:00
def test_against_sysdev_cpu_num(self):
ls = os.listdir("/sys/devices/system/cpu")
count = len([x for x in ls if re.search(r"cpu\d+$", x) is not None])
self.assertEqual(psutil.cpu_count(), count)
- @unittest.skipIf(not which("nproc"), "nproc utility not available")
+ @unittest.skip("Unreliable on mock")
def test_against_nproc(self):
num = int(sh("nproc --all"))
self.assertEqual(psutil.cpu_count(logical=True), num)
2024-02-09 13:32:48 +00:00
@@ -785,7 +780,7 @@ class TestSystemCPUCountLogical(PsutilTestCase):
2023-08-04 11:45:17 +00:00
assert m.called
-@unittest.skipIf(not LINUX, "LINUX only")
+@unittest.skip("Unreliable on mock")
class TestSystemCPUCountCores(PsutilTestCase):
@unittest.skipIf(not which("lscpu"), "lscpu utility not available")
2024-02-09 13:32:48 +00:00
def test_against_lscpu(self):
@@ -815,7 +810,7 @@ class TestSystemCPUCountCores(PsutilTestCase):
@unittest.skipIf(not LINUX, "LINUX only")
class TestSystemCPUFrequency(PsutilTestCase):
- @unittest.skipIf(not HAS_CPU_FREQ, "not supported")
2023-08-04 11:45:17 +00:00
+ @unittest.skip("Unreliable on mock")
def test_emulate_use_second_file(self):
# https://github.com/giampaolo/psutil/issues/981
def path_exists_mock(path):
2024-02-09 13:32:48 +00:00
@@ -830,7 +825,7 @@ class TestSystemCPUFrequency(PsutilTestCase):
):
assert psutil.cpu_freq()
- @unittest.skipIf(not HAS_CPU_FREQ, "not supported")
2023-08-04 11:45:17 +00:00
+ @unittest.skip("Unreliable on mock")
def test_emulate_use_cpuinfo(self):
# Emulate a case where /sys/devices/system/cpu/cpufreq* does not
# exist and /proc/cpuinfo is used instead.
2024-02-09 13:32:48 +00:00
@@ -964,7 +959,7 @@ class TestSystemCPUFrequency(PsutilTestCase):
self.assertEqual(freq.current, 200)
-@unittest.skipIf(not LINUX, "LINUX only")
2023-08-04 11:45:17 +00:00
+@unittest.skip("Unreliable on mock")
class TestSystemCPUStats(PsutilTestCase):
def test_ctx_switches(self):
2024-02-09 13:32:48 +00:00
vmstat_value = vmstat("context switches")
@@ -995,7 +990,7 @@ class TestLoadAvg(PsutilTestCase):
2023-07-11 05:41:06 +00:00
# =====================================================================
-@unittest.skipIf(not LINUX, "LINUX only")
2023-08-04 11:45:17 +00:00
+@unittest.skip("Unreliable on mock")
2023-07-11 05:41:06 +00:00
class TestSystemNetIfAddrs(PsutilTestCase):
def test_ips(self):
2024-02-09 13:32:48 +00:00
for name, addrs in psutil.net_if_addrs().items():
@@ -1404,7 +1399,7 @@ class TestRootFsDeviceFinder(PsutilTestCase):
2023-08-04 11:45:17 +00:00
self.assertRaises(FileNotFoundError, finder.ask_sys_dev_block)
2022-07-31 05:59:37 +00:00
finder.ask_sys_class_block()
2023-08-04 11:45:17 +00:00
- @unittest.skipIf(GITHUB_ACTIONS, "unsupported on GITHUB_ACTIONS")
+ @unittest.skip("Unreliable on mock")
2022-07-31 05:59:37 +00:00
def test_comparisons(self):
finder = RootFsDeviceFinder()
self.assertIsNotNone(finder.find())
2024-02-09 13:32:48 +00:00
@@ -1428,11 +1423,13 @@ class TestRootFsDeviceFinder(PsutilTestCase):
2023-08-04 11:45:17 +00:00
2022-07-31 05:59:37 +00:00
@unittest.skipIf(not which("findmnt"), "findmnt utility not available")
@unittest.skipIf(GITHUB_ACTIONS, "unsupported on GITHUB_ACTIONS")
2023-08-04 11:45:17 +00:00
+ @unittest.skip("Unreliable on mock")
2022-07-31 05:59:37 +00:00
def test_against_findmnt(self):
psutil_value = RootFsDeviceFinder().find()
findmnt_value = sh("findmnt -o SOURCE -rn /")
self.assertEqual(psutil_value, findmnt_value)
2023-08-04 11:45:17 +00:00
+ @unittest.skip("Unreliable on mock")
2022-07-31 05:59:37 +00:00
def test_disk_partitions_mocked(self):
with mock.patch(
2024-02-09 13:32:48 +00:00
'psutil._pslinux.cext.disk_partitions',
@@ -2112,6 +2109,7 @@ class TestProcess(PsutilTestCase):
with mock.patch(patch_point, side_effect=open_mock_2):
self.assertRaises(psutil.AccessDenied, psutil.Process().threads)
2023-08-04 11:45:17 +00:00
+ @unittest.skip("Unreliable on mock")
2024-02-09 13:32:48 +00:00
def test_exe_mocked(self):
with mock.patch(
'psutil._pslinux.readlink', side_effect=OSError(errno.ENOENT, "")
@@ -2313,6 +2311,7 @@ class TestProcessAgainstStatus(PsutilTestCase):
2023-08-04 11:45:17 +00:00
value = self.read_status_file("nonvoluntary_ctxt_switches:")
self.assertEqual(self.proc.num_ctx_switches().involuntary, value)
+ @unittest.skip("Unreliable on mock")
def test_cpu_affinity(self):
value = self.read_status_file("Cpus_allowed_list:")
if '-' in str(value):
2024-02-09 13:32:48 +00:00
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index 152e378..35542f5 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -561,11 +561,7 @@ class TestCpuAPIs(PsutilTestCase):
2023-08-04 13:19:08 +00:00
if not AIX and name in ('ctx_switches', 'interrupts'):
self.assertGreater(value, 0)
- # TODO: remove this once 1892 is fixed
2024-02-09 13:32:48 +00:00
- @unittest.skipIf(
- MACOS and platform.machine() == 'arm64', "skipped due to #1892"
- )
2023-08-04 13:19:08 +00:00
- @unittest.skipIf(not HAS_CPU_FREQ, "not supported")
+ @unittest.skip("Unreliable on mock")
def test_cpu_freq(self):
def check_ls(ls):
for nt in ls:
2024-02-09 13:32:48 +00:00
diff --git a/psutil/tests/test_testutils.py b/psutil/tests/test_testutils.py
index a93f9f0..59ae083 100755
--- a/psutil/tests/test_testutils.py
+++ b/psutil/tests/test_testutils.py
@@ -373,7 +373,7 @@ class TestMemLeakClass(TestMemoryLeak):
2021-01-11 00:11:39 +00:00
self.assertRaises(ValueError, self.execute, lambda: 0, retries=-1)
@retry_on_failure()
- @unittest.skipIf(CI_TESTING, "skipped on CI")
+ @unittest.skip("Unreliable in mock")
2023-08-04 11:45:17 +00:00
@unittest.skipIf(COVERAGE, "skipped during test coverage")
2021-01-11 00:11:39 +00:00
def test_leak_mem(self):
ls = []