summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-01-20 12:26:36 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-01-20 13:25:11 -0500
commit867235e4902c91531095676e3a413d935181b0bd (patch)
tree921c46b34c1c95f9f2e6ca1b5c75bc8f06e2888b /lib/sqlalchemy/testing
parentc6b15e443e0cfc7a09eb24c37123a595fdb639ca (diff)
downloadsqlalchemy-867235e4902c91531095676e3a413d935181b0bd.tar.gz
repair broken truediv test suite; memusage
the truediv test suite didn't have __backend__ so wasn't running for every DB except in the main build. Repaired this as well as truediv support to preserve the right-hand side type when casting to numeric, if the right type is already a numeric type. also fixed a memusage test that relies on savepoints so was not running under gerrit runs. Change-Id: I3be223fdf697af9c1ed61b70d621f57cbbb7a92b
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/suite/test_types.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py
index 796de5d93..c51a66690 100644
--- a/lib/sqlalchemy/testing/suite/test_types.py
+++ b/lib/sqlalchemy/testing/suite/test_types.py
@@ -533,6 +533,8 @@ class CastTypeDecoratorTest(_LiteralRoundTripFixture, fixtures.TestBase):
class TrueDivTest(fixtures.TestBase):
+ __backend__ = True
+
@testing.combinations(
("15", "10", 1.5),
("-15", "10", -1.5),
@@ -576,14 +578,30 @@ class TrueDivTest(fixtures.TestBase):
eq_(
connection.scalar(
select(
- literal_column(left, type_=Numeric())
- / literal_column(right, type_=Numeric())
+ literal_column(left, type_=Numeric(10, 2))
+ / literal_column(right, type_=Numeric(10, 2))
)
),
decimal.Decimal(expected),
)
@testing.combinations(
+ ("5.52", "2.4", 2.3), argnames="left, right, expected"
+ )
+ def test_truediv_float(self, connection, left, right, expected):
+ """test #4926"""
+
+ eq_(
+ connection.scalar(
+ select(
+ literal_column(left, type_=Float())
+ / literal_column(right, type_=Float())
+ )
+ ),
+ expected,
+ )
+
+ @testing.combinations(
("5.52", "2.4", "2.0"), argnames="left, right, expected"
)
def test_floordiv_numeric(self, connection, left, right, expected):