Skip to content

Commit 313ef8b

Browse files
James Pagepriteau
authored andcommitted
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
1 parent 3d55cee commit 313ef8b

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cloudkitty/tests/gabbi/gabbits/v1-report.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ tests:
7676
service: "cpu"
7777
status: 200
7878
response_strings:
79-
- "224.616"
79+
- "/(224.61)(\\d)*/"
8080

8181
- name: get total for a period filtering on image service
8282
url: /v1/report/total

cloudkitty/tests/storage/v1/test_storage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ def test_get_total_without_filter_but_timestamp(self):
156156
end=end)['results']
157157
# FIXME(sheeprine): floating point error (transition to decimal)
158158
self.assertEqual(1, len(total))
159-
self.assertEqual(1.9473999999999998, total[0]["rate"])
159+
self.assertAlmostEqual(
160+
1.9473999999999998, total[0]["rate"], delta=0.001)
160161
self.assertEqual(begin, total[0]["begin"])
161162
self.assertEqual(end, total[0]["end"])
162163

0 commit comments

Comments
 (0)