Blame 0001-fix-geopos-test.patch

06abfb
From: Matthias Fehring <buschmann23@opensuse.org>
06abfb
Date: 2022-0119 13:40:00 +0100
06abfb
Subject: fix floating point comparison in test
06abfb
Upstream: no
06abfb
06abfb
The returned floating point values are slightly different from
06abfb
the reference values. Upstreams mentions this and already uses adopted
06abfb
reference values, but different python versions still return slightly
06abfb
different values. This patch uses math.isclose instead of comparison
06abfb
operator.
06abfb
06abfb
---
06abfb
 test_commands.py |   11 +++++++----
06abfb
 1 file changed, 7 insertions(+), 4 deletions(-)
06abfb
06abfb
--- a/tests/test_commands.py	2021-12-27 21:28:05.000000000 +0100
06abfb
+++ b/tests/test_commands.py	2022-01-19 13:32:59.075905731 +0100
06abfb
@@ -5,6 +5,7 @@ import time
06abfb
 from string import ascii_letters
06abfb
 
06abfb
 import pytest
06abfb
+import math
06abfb
 
06abfb
 import aioredis
06abfb
 from aioredis import exceptions
06abfb
@@ -2170,10 +2171,12 @@ class TestRedisCommands:
06abfb
 
06abfb
         await r.geoadd("barcelona", *values)
06abfb
         # redis uses 52 bits precision, hereby small errors may be introduced.
06abfb
-        assert await r.geopos("barcelona", "place1", "place2") == [
06abfb
-            (2.19093829393386841, 41.43379028184083523),
06abfb
-            (2.18737632036209106, 41.40634178640635099),
06abfb
-        ]
06abfb
+        positions = await r.geopos("barcelona", "place1", "place2")
06abfb
+
06abfb
+        assert math.isclose(positions[0][0], 2.19093829393386841, rel_tol=1e-5)
06abfb
+        assert math.isclose(positions[0][1], 41.43379028184083523, rel_tol=1e-5)
06abfb
+        assert math.isclose(positions[1][0], 2.18737632036209106, rel_tol=1e-5)
06abfb
+        assert math.isclose(positions[1][1], 41.40634178640635099, rel_tol=1e-5)
06abfb
 
06abfb
     @skip_if_server_version_lt("4.0.0")
06abfb
     async def test_geopos_no_value(self, r: aioredis.Redis):