]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Increase tolerance in float4 tests
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 28 Jul 2021 16:50:57 +0000 (18:50 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 28 Jul 2021 16:50:57 +0000 (18:50 +0200)
The default tolerance is not quite enough on Postgres < 12 (e.g.
-13.633 != pytest.approx(-13.63298) with the default tolerance of 1e-6)

tests/fix_faker.py

index 530cb3bcd6e928d11ed4b16e6851583f58dd6f9b..724cb7a8cc684176c94f850652e0d7ce11761b3f 100644 (file)
@@ -371,7 +371,7 @@ class Faker:
                 (0.0, -0.0, float("-inf"), float("inf"), float("nan"))
             )
 
-    def match_float(self, spec, got, want, approx=False):
+    def match_float(self, spec, got, want, approx=False, rel=None):
         if got is not None and isnan(got):
             assert isnan(want)
         else:
@@ -381,13 +381,13 @@ class Faker:
             if not approx and self.conn.info.server_version >= 120000:
                 assert got == want
             else:
-                assert got == pytest.approx(want)
+                assert got == pytest.approx(want, rel=rel)
 
     def make_Float4(self, spec):
         return spec(self.make_float(spec, double=False))
 
     def match_Float4(self, spec, got, want):
-        return self.match_float(spec, got, want, approx=True)
+        return self.match_float(spec, got, want, approx=True, rel=1e-5)
 
     def make_Float8(self, spec):
         return spec(self.make_float(spec))