From: Daniele Varrazzo Date: Wed, 23 Jun 2021 12:10:57 +0000 (+0100) Subject: Fix rounding error in float comparison tests with postgres < 12 X-Git-Tag: 3.0.dev0~18^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=359e0e81a8e9d7adea7de5ee7fca1eb09bd7be7c;p=thirdparty%2Fpsycopg.git Fix rounding error in float comparison tests with postgres < 12 --- diff --git a/tests/fix_faker.py b/tests/fix_faker.py index 9c20e3689..e10b02730 100644 --- a/tests/fix_faker.py +++ b/tests/fix_faker.py @@ -318,7 +318,13 @@ class Faker: if got is not None and isnan(got): assert isnan(want) else: - assert got == want + # Versions older than 12 make some rounding. e.g. in Postgres 10.4 + # select '-1.409006204063909e+112'::float8 + # -> -1.40900620406391e+112 + if self.conn.info.server_version >= 120000: + assert got == want + else: + assert got == pytest.approx(want) def make_int(self, spec): return randrange(-(1 << 90), 1 << 90)