Skip to content

Commit

Permalink
chore: mark test_cpu_freq as expected failure on macOS arm64
Browse files Browse the repository at this point in the history
macOS arm64 does not support cpu_freq: issue giampaolo#1892

Signed-off-by: mayeut <mayeut@users.noreply.github.com>
  • Loading branch information
mayeut committed Oct 5, 2022
1 parent 7271ec7 commit 18ebd4d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
22 changes: 18 additions & 4 deletions psutil/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,17 @@
"HAS_IONICE", "HAS_MEMORY_MAPS", "HAS_PROC_CPU_NUM", "HAS_RLIMIT",
"HAS_SENSORS_BATTERY", "HAS_BATTERY", "HAS_SENSORS_FANS",
"HAS_SENSORS_TEMPERATURES", "HAS_MEMORY_FULL_INFO", "MACOS_11PLUS",
"MACOS_12PLUS",
"MACOS_12PLUS", "MACOS_ARM64",
# subprocesses
'pyrun', 'terminate', 'reap_children', 'spawn_testproc', 'spawn_zombie',
'spawn_children_pair',
# threads
'ThreadTask'
# test utils
'unittest', 'skip_on_access_denied', 'skip_on_not_implemented',
'retry_on_failure', 'TestMemoryLeak', 'PsutilTestCase',
'process_namespace', 'system_namespace', 'print_sysinfo',
'expectedFailureIf', 'unittest', 'skip_on_access_denied',
'skip_on_not_implemented', 'retry_on_failure', 'TestMemoryLeak',
'PsutilTestCase', 'process_namespace', 'system_namespace',
'print_sysinfo',
# install utils
'install_pip', 'install_test_deps',
# fs utils
Expand Down Expand Up @@ -130,6 +131,7 @@
CI_TESTING = APPVEYOR or GITHUB_ACTIONS
# are we a 64 bit process?
IS_64BIT = sys.maxsize > 2 ** 32
MACOS_ARM64 = MACOS and platform.machine() == 'arm64'


@memoize
Expand Down Expand Up @@ -901,6 +903,18 @@ def subTest(self, *args, **kw):
unittest.TestCase = TestCase


def expectedFailureIf(condition):
"""The test is marked as an expectedFailure if the condition is
satisfied.
"""
def wrapper(func):
if condition:
return unittest.expectedFailure(func)
else:
return func
return wrapper


class PsutilTestCase(TestCase):
"""Test class providing auto-cleanup wrappers on top of process
test utilities.
Expand Down
3 changes: 3 additions & 0 deletions psutil/tests/test_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
from psutil.tests import HAS_NET_IO_COUNTERS
from psutil.tests import HAS_SENSORS_FANS
from psutil.tests import HAS_SENSORS_TEMPERATURES
from psutil.tests import MACOS_ARM64
from psutil.tests import PYPY
from psutil.tests import SKIP_SYSCONS
from psutil.tests import VALID_PROC_STATUSES
from psutil.tests import PsutilTestCase
from psutil.tests import check_connection_ntuple
from psutil.tests import create_sockets
from psutil.tests import enum
from psutil.tests import expectedFailureIf
from psutil.tests import is_namedtuple
from psutil.tests import kernel_version
from psutil.tests import process_namespace
Expand Down Expand Up @@ -236,6 +238,7 @@ def test_cpu_count(self):
self.assertIsInstance(psutil.cpu_count(), int)

@unittest.skipIf(not HAS_CPU_FREQ, "not supported")
@expectedFailureIf(MACOS_ARM64) # macOS arm64 not supported: issue #1892
def test_cpu_freq(self):
if psutil.cpu_freq() is None:
raise self.skipTest("cpu_freq() returns None")
Expand Down
3 changes: 3 additions & 0 deletions psutil/tests/test_memleaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
from psutil.tests import HAS_SENSORS_BATTERY
from psutil.tests import HAS_SENSORS_FANS
from psutil.tests import HAS_SENSORS_TEMPERATURES
from psutil.tests import MACOS_ARM64
from psutil.tests import TestMemoryLeak
from psutil.tests import create_sockets
from psutil.tests import expectedFailureIf
from psutil.tests import get_testfn
from psutil.tests import process_namespace
from psutil.tests import skip_on_access_denied
Expand Down Expand Up @@ -365,6 +367,7 @@ def test_cpu_stats(self):

@fewtimes_if_linux()
@unittest.skipIf(not HAS_CPU_FREQ, "not supported")
@expectedFailureIf(MACOS_ARM64) # macOS arm64 not supported: issue #1892
def test_cpu_freq(self):
self.execute(psutil.cpu_freq)

Expand Down
3 changes: 3 additions & 0 deletions psutil/tests/test_osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
from psutil import MACOS
from psutil import POSIX
from psutil.tests import HAS_BATTERY
from psutil.tests import MACOS_ARM64
from psutil.tests import TOLERANCE_DISK_USAGE
from psutil.tests import TOLERANCE_SYS_MEM
from psutil.tests import PsutilTestCase
from psutil.tests import expectedFailureIf
from psutil.tests import retry_on_failure
from psutil.tests import sh
from psutil.tests import spawn_testproc
Expand Down Expand Up @@ -144,6 +146,7 @@ def test_cpu_count_cores(self):
num = sysctl("sysctl hw.physicalcpu")
self.assertEqual(num, psutil.cpu_count(logical=False))

@expectedFailureIf(MACOS_ARM64) # macOS arm64 not supported: issue #1892
def test_cpu_freq(self):
freq = psutil.cpu_freq()
self.assertEqual(
Expand Down
3 changes: 3 additions & 0 deletions psutil/tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@
from psutil.tests import HAS_SENSORS_TEMPERATURES
from psutil.tests import IS_64BIT
from psutil.tests import MACOS_12PLUS
from psutil.tests import MACOS_ARM64
from psutil.tests import PYPY
from psutil.tests import UNICODE_SUFFIX
from psutil.tests import PsutilTestCase
from psutil.tests import check_net_address
from psutil.tests import enum
from psutil.tests import expectedFailureIf
from psutil.tests import mock
from psutil.tests import retry_on_failure

Expand Down Expand Up @@ -512,6 +514,7 @@ def test_cpu_stats(self):
self.assertGreater(value, 0)

@unittest.skipIf(not HAS_CPU_FREQ, "not supported")
@expectedFailureIf(MACOS_ARM64) # macOS arm64 not supported: issue #1892
def test_cpu_freq(self):
def check_ls(ls):
for nt in ls:
Expand Down

0 comments on commit 18ebd4d

Please sign in to comment.