From 5eb407f84bdabdbcd68975dbf76dc4c0809d7373 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Tue, 14 Sep 2021 23:38:00 +0200 Subject: Added support for ``psycopg`` dialect. Both sync and async versions are supported. Fixes: #6842 Change-Id: I57751c5028acebfc6f9c43572562405453a2f2a4 --- lib/sqlalchemy/testing/config.py | 5 +++-- lib/sqlalchemy/testing/plugin/plugin_base.py | 3 ++- lib/sqlalchemy/testing/requirements.py | 10 ++++++++++ lib/sqlalchemy/testing/suite/test_results.py | 2 ++ lib/sqlalchemy/testing/suite/test_types.py | 8 +++++++- 5 files changed, 24 insertions(+), 4 deletions(-) (limited to 'lib/sqlalchemy/testing') diff --git a/lib/sqlalchemy/testing/config.py b/lib/sqlalchemy/testing/config.py index 8faeea634..22d9c523a 100644 --- a/lib/sqlalchemy/testing/config.py +++ b/lib/sqlalchemy/testing/config.py @@ -124,11 +124,12 @@ class Config: _configs = set() def _set_name(self, db): + suffix = "_async" if db.dialect.is_async else "" if db.dialect.server_version_info: svi = ".".join(str(tok) for tok in db.dialect.server_version_info) - self.name = "%s+%s_[%s]" % (db.name, db.driver, svi) + self.name = "%s+%s%s_[%s]" % (db.name, db.driver, suffix, svi) else: - self.name = "%s+%s" % (db.name, db.driver) + self.name = "%s+%s%s" % (db.name, db.driver, suffix) @classmethod def register(cls, db, db_opts, options, file_config): diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 32ed2c315..d79931b91 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -706,7 +706,8 @@ def _do_skips(cls): ) if not all_configs: - msg = "'%s' unsupported on any DB implementation %s%s" % ( + msg = "'%s.%s' unsupported on any DB implementation %s%s" % ( + cls.__module__, cls.__name__, ", ".join( "'%s(%s)+%s'" diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index 8cb72d163..f811be657 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -1493,3 +1493,13 @@ class SuiteRequirements(Requirements): sequence. This should be false only for oracle. """ return exclusions.open() + + @property + def generic_classes(self): + "If X[Y] can be implemented with ``__class_getitem__``. py3.7+" + return exclusions.open() + + @property + def json_deserializer_binary(self): + "indicates if the json_deserializer function is called with bytes" + return exclusions.closed() diff --git a/lib/sqlalchemy/testing/suite/test_results.py b/lib/sqlalchemy/testing/suite/test_results.py index 5ad68034b..a8900ece1 100644 --- a/lib/sqlalchemy/testing/suite/test_results.py +++ b/lib/sqlalchemy/testing/suite/test_results.py @@ -244,6 +244,8 @@ class ServerSideCursorsTest( return cursor.server_side elif self.engine.dialect.driver == "pg8000": return getattr(cursor, "server_side", False) + elif self.engine.dialect.driver == "psycopg": + return bool(getattr(cursor, "name", False)) else: return False diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index 82e6fa238..e7131ec6e 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -1107,7 +1107,13 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest): eq_(row, (data_element,)) eq_(js.mock_calls, [mock.call(data_element)]) - eq_(jd.mock_calls, [mock.call(json.dumps(data_element))]) + if testing.requires.json_deserializer_binary.enabled: + eq_( + jd.mock_calls, + [mock.call(json.dumps(data_element).encode())], + ) + else: + eq_(jd.mock_calls, [mock.call(json.dumps(data_element))]) @testing.combinations( ("parameters",), -- cgit v1.2.1