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
This commit is contained in:
James Page 2024-04-11 12:28:49 +01:00 committed by Pierre Riteau
parent 3d55ceed63
commit 313ef8b110
2 changed files with 3 additions and 2 deletions

View File

@ -76,7 +76,7 @@ tests:
service: "cpu" service: "cpu"
status: 200 status: 200
response_strings: response_strings:
- "224.616" - "/(224.61)(\\d)*/"
- name: get total for a period filtering on image service - name: get total for a period filtering on image service
url: /v1/report/total url: /v1/report/total

View File

@ -156,7 +156,8 @@ class StorageTotalTest(StorageTest):
end=end)['results'] end=end)['results']
# FIXME(sheeprine): floating point error (transition to decimal) # FIXME(sheeprine): floating point error (transition to decimal)
self.assertEqual(1, len(total)) 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(begin, total[0]["begin"])
self.assertEqual(end, total[0]["end"]) self.assertEqual(end, total[0]["end"])