From 882c465b45d5b68db27cc1ea01b922d915edfca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 9 Feb 2024 15:01:24 +0100 Subject: [PATCH] Workaround float comparison precision errors in c10s Koji --- 2372.patch | 54 ++++++++++++++++++++++++++++++++++++++++++++++ python-psutil.spec | 4 ++++ 2 files changed, 58 insertions(+) create mode 100644 2372.patch diff --git a/2372.patch b/2372.patch new file mode 100644 index 0000000..aea906a --- /dev/null +++ b/2372.patch @@ -0,0 +1,54 @@ +From 7664f36157268dba47313043da27761727c813ab Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Fri, 9 Feb 2024 14:55:41 +0100 +Subject: [PATCH] Tests: Compare floats less strictly + +We see: + + ====================================================================== + FAIL: psutil.tests.test_system.TestCpuAPIs.test_cpu_times + ---------------------------------------------------------------------- + Traceback (most recent call last): + File "/builddir/build/BUILD/psutil-release-5.9.5/psutil/tests/test_system.py", line 351, in test_cpu_times + self.assertAlmostEqual(total, sum(times)) + AssertionError: 885725913.3 != 885725913.3000001 within 7 places (1.1920928955078125e-07 difference) + ---------------------------------------------------------------------- + +Or: + + ====================================================================== + FAIL: psutil.tests.test_system.TestCpuAPIs.test_cpu_times + ---------------------------------------------------------------------- + Traceback (most recent call last): + File "/builddir/build/BUILD/psutil-release-5.9.5/psutil/tests/test_system.py", line 351, in test_cpu_times + self.assertAlmostEqual(total, sum(times)) + AssertionError: 324284741.90999997 != 324284741.91 within 7 places (5.960464477539063e-08 difference) + ---------------------------------------------------------------------- + +In CentOS Stream 10 builds on i686 and x86_64. +--- + psutil/tests/test_system.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/psutil/tests/test_system.py b/psutil/tests/test_system.py +index 6656c19ba..56979c927 100755 +--- a/psutil/tests/test_system.py ++++ b/psutil/tests/test_system.py +@@ -385,7 +385,7 @@ def test_cpu_times(self): + self.assertIsInstance(cp_time, float) + self.assertGreaterEqual(cp_time, 0.0) + total += cp_time +- self.assertAlmostEqual(total, sum(times)) ++ self.assertAlmostEqual(total, sum(times), places=6) + str(times) + # CPU times are always supposed to increase over time + # or at least remain the same and that's because time +@@ -424,7 +424,7 @@ def test_per_cpu_times(self): + self.assertIsInstance(cp_time, float) + self.assertGreaterEqual(cp_time, 0.0) + total += cp_time +- self.assertAlmostEqual(total, sum(times)) ++ self.assertAlmostEqual(total, sum(times), places=6) + str(times) + self.assertEqual( + len(psutil.cpu_times(percpu=True)[0]), diff --git a/python-psutil.spec b/python-psutil.spec index 01fe208..636dfd0 100644 --- a/python-psutil.spec +++ b/python-psutil.spec @@ -10,6 +10,10 @@ Source: %{url}/archive/release-%{version}/psutil-%{version}.tar.gz # skip tests that fail in mock chroots # Patch: python-psutil-skip-tests-in-mock.patch +# +# avoid: AssertionError: 885725913.3 != 885725913.3000001 within 7 places +# +Patch: https://github.com/giampaolo/psutil/pull/2372.patch BuildRequires: gcc BuildRequires: sed