1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
From: Chris Lamb <lamby@debian.org>
Date: Wed, 28 May 2025 14:28:24 -0700
Subject: Use math.isclose over testing for floating point equality
---
tests/test_asyncio/test_commands.py | 3 ++-
tests/test_commands.py | 5 +++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/tests/test_asyncio/test_commands.py b/tests/test_asyncio/test_commands.py
index cc7b9a6..952e974 100644
--- a/tests/test_asyncio/test_commands.py
+++ b/tests/test_asyncio/test_commands.py
@@ -5,6 +5,7 @@ Tests async overrides of commands from their mixins
import asyncio
import binascii
import datetime
+import math
import re
import sys
from string import ascii_letters
@@ -2936,7 +2937,7 @@ class TestRedisCommands:
"barcelona", 2.191, 41.433, 1000, store_dist="places_barcelona"
)
# instead of save the geo score, the distance is saved.
- assert await r.zscore("places_barcelona", "place1") == 88.05060698409301
+ assert math.isclose(await r.zscore("places_barcelona", "place1"), 88.05060698409301)
@skip_unless_arch_bits(64)
@skip_if_server_version_lt("3.2.0")
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 5d4e7ec..4cf652a 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -1,5 +1,6 @@
import binascii
import datetime
+import math
import re
import threading
import time
@@ -4140,7 +4141,7 @@ class TestRedisCommands:
storedist=True,
)
# instead of save the geo score, the distance is saved.
- assert r.zscore("places_barcelona", "place1") == 88.05060698409301
+ assert math.isclose(r.zscore("places_barcelona", "place1"), 88.05060698409301)
@skip_if_server_version_lt("3.2.0")
def test_georadius_Issue2609(self, r):
@@ -4296,7 +4297,7 @@ class TestRedisCommands:
r.geoadd("barcelona", values)
r.georadius("barcelona", 2.191, 41.433, 1000, store_dist="places_barcelona")
# instead of save the geo score, the distance is saved.
- assert r.zscore("places_barcelona", "place1") == 88.05060698409301
+ assert math.isclose(r.zscore("places_barcelona", "place1"), 88.05060698409301)
@skip_unless_arch_bits(64)
@skip_if_server_version_lt("3.2.0")
|