From 313ef8b110508885663644ea839f7340a8fbdb2a Mon Sep 17 00:00:00 2001 From: James Page Date: Thu, 11 Apr 2024 12:28:49 +0100 Subject: [PATCH] Fix test suite with Python 3.12 Comparison of floats is always tricky. Use assertAlmostEqual instead of assertEqual and fix a Gabbi test with a regular expression. Change-Id: Ifa822f47830fde4cebf59a54c2c2be3ec8f2f02f --- cloudkitty/tests/gabbi/gabbits/v1-report.yaml | 2 +- cloudkitty/tests/storage/v1/test_storage.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cloudkitty/tests/gabbi/gabbits/v1-report.yaml b/cloudkitty/tests/gabbi/gabbits/v1-report.yaml index 7d47b6c1..841ee328 100644 --- a/cloudkitty/tests/gabbi/gabbits/v1-report.yaml +++ b/cloudkitty/tests/gabbi/gabbits/v1-report.yaml @@ -76,7 +76,7 @@ tests: service: "cpu" status: 200 response_strings: - - "224.616" + - "/(224.61)(\\d)*/" - name: get total for a period filtering on image service url: /v1/report/total diff --git a/cloudkitty/tests/storage/v1/test_storage.py b/cloudkitty/tests/storage/v1/test_storage.py index d18f8caa..52a8586a 100644 --- a/cloudkitty/tests/storage/v1/test_storage.py +++ b/cloudkitty/tests/storage/v1/test_storage.py @@ -156,7 +156,8 @@ class StorageTotalTest(StorageTest): end=end)['results'] # FIXME(sheeprine): floating point error (transition to decimal) self.assertEqual(1, len(total)) - self.assertEqual(1.9473999999999998, total[0]["rate"]) + self.assertAlmostEqual( + 1.9473999999999998, total[0]["rate"], delta=0.001) self.assertEqual(begin, total[0]["begin"]) self.assertEqual(end, total[0]["end"])