summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/testing/schema.py')
-rw-r--r--lib/sqlalchemy/testing/schema.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/schema.py b/lib/sqlalchemy/testing/schema.py
index f5bd1f7a2..8e26d2eaf 100644
--- a/lib/sqlalchemy/testing/schema.py
+++ b/lib/sqlalchemy/testing/schema.py
@@ -9,6 +9,7 @@ from . import config
from . import exclusions
from .. import event
from .. import schema
+from .. import types as sqltypes
__all__ = ["Table", "Column"]
@@ -115,6 +116,43 @@ def Column(*args, **kw):
return col
+class eq_type_affinity(object):
+ """Helper to compare types inside of datastructures based on affinity.
+
+ E.g.::
+
+ eq_(
+ inspect(connection).get_columns("foo"),
+ [
+ {
+ "name": "id",
+ "type": testing.eq_type_affinity(sqltypes.INTEGER),
+ "nullable": False,
+ "default": None,
+ "autoincrement": False,
+ },
+ {
+ "name": "data",
+ "type": testing.eq_type_affinity(sqltypes.NullType),
+ "nullable": True,
+ "default": None,
+ "autoincrement": False,
+ },
+ ],
+ )
+
+ """
+
+ def __init__(self, target):
+ self.target = sqltypes.to_instance(target)
+
+ def __eq__(self, other):
+ return self.target._type_affinity is other._type_affinity
+
+ def __ne__(self, other):
+ return self.target._type_affinity is not other._type_affinity
+
+
def _truncate_name(dialect, name):
if len(name) > dialect.max_identifier_length:
return (