From: Mike Bayer Date: Wed, 15 Feb 2023 23:28:12 +0000 (-0500) Subject: prevent float tests from running on asyncmy X-Git-Tag: rel_1_4_47~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81dd922cf79f4df0eafceb2e5092915d79d72853;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git prevent float tests from running on asyncmy asyncmy 0.2.7 has had a loss in float precision for even very low numbers of significant digits. Change-Id: Iec6d2650943eeaa8e854f21990f6565d73331f8c References: https://github.com/long2ice/asyncmy/issues/56 (cherry picked from commit 8855656626202e541bd2c95bc023e820a022322f) --- diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index 0e8eec52d6..0b2e059d0a 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -1043,6 +1043,20 @@ class SuiteRequirements(Requirements): """ return exclusions.open() + @property + def literal_float_coercion(self): + """target backend will return the exact float value 15.7563 + with only four significant digits from this statement: + + SELECT :param + + where :param is the Python float 15.7563 + + i.e. it does not return 15.75629997253418 + + """ + return exclusions.open() + @property def floats_to_four_decimals(self): """target backend can return a floating-point number with four diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index b96350ed07..6dc5089575 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -692,6 +692,7 @@ class NumericTest(_LiteralRoundTripFixture, fixtures.TestBase): filter_=lambda n: n is not None and round(n, 5) or None, ) + @testing.requires.literal_float_coercion def test_float_coerce_round_trip(self, connection): expr = 15.7563 @@ -941,10 +942,7 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest): ("integer", None), ("float", 28.5), ("float", None), - ( - "float", - 1234567.89, - ), + ("float", 1234567.89, testing.requires.literal_float_coercion), ("numeric", 1234567.89), # this one "works" because the float value you see here is # lost immediately to floating point stuff diff --git a/test/dialect/mysql/test_types.py b/test/dialect/mysql/test_types.py index 017fad3cff..358b814b92 100644 --- a/test/dialect/mysql/test_types.py +++ b/test/dialect/mysql/test_types.py @@ -474,6 +474,8 @@ class TypeRoundTripTest(fixtures.TestBase, AssertsExecutionResults): # fixed in mysql-connector as of 2.0.1, # see https://bugs.mysql.com/bug.php?id=73266 + + @testing.requires.literal_float_coercion def test_precision_float_roundtrip(self, metadata, connection): t = Table( "t", diff --git a/test/requirements.py b/test/requirements.py index fa9ba88f58..47f5c49eb3 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -1360,6 +1360,10 @@ class DefaultRequirements(SuiteRequirements): ] ) + @property + def literal_float_coercion(self): + return skip_if("+asyncmy") + @property def infinity_floats(self): return fails_on_everything_except(