From: Daniele Varrazzo Date: Wed, 28 Jul 2021 16:50:57 +0000 (+0200) Subject: Increase tolerance in float4 tests X-Git-Tag: 3.0.dev2~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=678e9876a838d457d2203e387cf3a35ef44ab41c;p=thirdparty%2Fpsycopg.git Increase tolerance in float4 tests 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) --- diff --git a/tests/fix_faker.py b/tests/fix_faker.py index 530cb3bcd..724cb7a8c 100644 --- a/tests/fix_faker.py +++ b/tests/fix_faker.py @@ -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))