File pytest9.patch of Package python-psutil
From 40e27872d534ed849245fdb0c4604ca678d5e9fc Mon Sep 17 00:00:00 2001
From: Giampaolo Rodola <g.rodola@gmail.com>
Date: Sun, 23 Nov 2025 00:08:41 +0100
Subject: [PATCH] Make ntuples work with subTest of new pytest release
When running tests in parallel, the new pytest 9.X is unable to
de/serialize nametuples when passed as:
with self.subTest(foo=ntuple):
...
---
tests/test_posix.py | 2 +-
tests/test_system.py | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/psutil/tests/test_posix.py b/psutil/tests/test_posix.py
index 2cc9dbd84c..ab2c10c9f3 100755
--- a/psutil/tests/test_posix.py
+++ b/psutil/tests/test_posix.py
@@ -416,7 +416,7 @@ def test_users_started(self):
if not tstamp:
return pytest.skip(f"cannot interpret tstamp in who output\n{out}")
- with self.subTest(psutil=psutil.users(), who=out):
+ with self.subTest(psutil=str(psutil.users()), who=out):
for idx, u in enumerate(psutil.users()):
psutil_value = datetime.datetime.fromtimestamp(
u.started
diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py
index 79325c7599..c00ab6fb96 100755
--- a/psutil/tests/test_system.py
+++ b/psutil/tests/test_system.py
@@ -244,7 +244,7 @@ def test_users(self):
users = psutil.users()
assert users
for user in users:
- with self.subTest(user=user):
+ with self.subTest(user=str(user)):
assert user.name
assert isinstance(user.name, str)
assert isinstance(user.terminal, (str, type(None)))
@@ -488,7 +488,9 @@ def test_cpu_times_comparison(self):
per_cpu = psutil.cpu_times(percpu=True)
summed_values = base._make([sum(num) for num in zip(*per_cpu)])
for field in base._fields:
- with self.subTest(field=field, base=base, per_cpu=per_cpu):
+ with self.subTest(
+ field=field, base=str(base), per_cpu=str(per_cpu)
+ ):
assert (
abs(getattr(base, field) - getattr(summed_values, field))
< 2