summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2022-01-21 01:26:02 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2022-01-21 01:26:02 +0000
commitf8a13c3dc751123eeefa2b475916a74aab99f023 (patch)
tree59e0c8cc1b5b8c115f7ae5fb193522292a44b848 /lib/sqlalchemy/testing
parent1a24813bab99376ccd1c726dd7b69db3635a2d2b (diff)
parent469f7fd2f3d51796904cde63dfcc2aafe5663087 (diff)
downloadsqlalchemy-f8a13c3dc751123eeefa2b475916a74aab99f023.tar.gz
Merge "re-enable tests for asyncmy; fix Binary" into main
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/suite/test_types.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py
index c51a66690..94bab009a 100644
--- a/lib/sqlalchemy/testing/suite/test_types.py
+++ b/lib/sqlalchemy/testing/suite/test_types.py
@@ -42,6 +42,8 @@ from ... import Unicode
from ... import UnicodeText
from ...orm import declarative_base
from ...orm import Session
+from ...sql.sqltypes import LargeBinary
+from ...sql.sqltypes import PickleType
class _LiteralRoundTripFixture:
@@ -193,6 +195,42 @@ class UnicodeTextTest(_UnicodeFixture, fixtures.TablesTest):
self._test_null_strings(connection)
+class BinaryTest(_LiteralRoundTripFixture, fixtures.TablesTest):
+ __requires__ = ("binary_literals",)
+ __backend__ = True
+
+ @classmethod
+ def define_tables(cls, metadata):
+ Table(
+ "binary_table",
+ metadata,
+ Column(
+ "id", Integer, primary_key=True, test_needs_autoincrement=True
+ ),
+ Column("binary_data", LargeBinary),
+ Column("pickle_data", PickleType),
+ )
+
+ def test_binary_roundtrip(self, connection):
+ binary_table = self.tables.binary_table
+
+ connection.execute(
+ binary_table.insert(), {"id": 1, "binary_data": b"this is binary"}
+ )
+ row = connection.execute(select(binary_table.c.binary_data)).first()
+ eq_(row, (b"this is binary",))
+
+ def test_pickle_roundtrip(self, connection):
+ binary_table = self.tables.binary_table
+
+ connection.execute(
+ binary_table.insert(),
+ {"id": 1, "pickle_data": {"foo": [1, 2, 3], "bar": "bat"}},
+ )
+ row = connection.execute(select(binary_table.c.pickle_data)).first()
+ eq_(row, ({"foo": [1, 2, 3], "bar": "bat"},))
+
+
class TextTest(_LiteralRoundTripFixture, fixtures.TablesTest):
__requires__ = ("text_type",)
__backend__ = True
@@ -1553,6 +1591,7 @@ class JSONLegacyStringCastIndexTest(
__all__ = (
+ "BinaryTest",
"UnicodeVarcharTest",
"UnicodeTextTest",
"JSONTest",