diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2022-01-21 01:26:02 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-01-21 01:26:02 +0000 |
| commit | f8a13c3dc751123eeefa2b475916a74aab99f023 (patch) | |
| tree | 59e0c8cc1b5b8c115f7ae5fb193522292a44b848 /lib/sqlalchemy/testing | |
| parent | 1a24813bab99376ccd1c726dd7b69db3635a2d2b (diff) | |
| parent | 469f7fd2f3d51796904cde63dfcc2aafe5663087 (diff) | |
| download | sqlalchemy-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.py | 39 |
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", |
