diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-06 12:37:53 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-01-06 13:22:59 -0500 |
commit | b6e3fae3f51e46028fa33e0bbc62fb2bce08b963 (patch) | |
tree | 8f41e9a70317c2181c57c0ef2bbb4680f14b9978 /tests/test_external_dialect.py | |
parent | 16c905b5f2a24ee7bdb766f9b60ce68e44b7dab0 (diff) | |
download | alembic-b6e3fae3f51e46028fa33e0bbc62fb2bce08b963.tar.gz |
pure black run + flake8
run black -l 79 against source code, set up for
full flake8 testing.
Change-Id: I4108e1274d49894b9898ec5bd3a1147933a473d7
Diffstat (limited to 'tests/test_external_dialect.py')
-rw-r--r-- | tests/test_external_dialect.py | 85 |
1 files changed, 47 insertions, 38 deletions
diff --git a/tests/test_external_dialect.py b/tests/test_external_dialect.py index dc01b75..1c3222d 100644 --- a/tests/test_external_dialect.py +++ b/tests/test_external_dialect.py @@ -15,6 +15,7 @@ from sqlalchemy.engine import default class CustomDialect(default.DefaultDialect): name = "custom_dialect" + try: from sqlalchemy.dialects import registry except ImportError: @@ -24,20 +25,22 @@ else: class CustomDialectImpl(impl.DefaultImpl): - __dialect__ = 'custom_dialect' + __dialect__ = "custom_dialect" transactional_ddl = False def render_type(self, type_, autogen_context): if type_.__module__ == __name__: autogen_context.imports.add( - "from %s import custom_dialect_types" % (__name__, )) + "from %s import custom_dialect_types" % (__name__,) + ) is_external = True else: is_external = False - if is_external and \ - hasattr(self, '_render_%s_type' % type_.__visit_name__): - meth = getattr(self, '_render_%s_type' % type_.__visit_name__) + if is_external and hasattr( + self, "_render_%s_type" % type_.__visit_name__ + ): + meth = getattr(self, "_render_%s_type" % type_.__visit_name__) return meth(type_, autogen_context) if is_external: @@ -47,13 +50,16 @@ class CustomDialectImpl(impl.DefaultImpl): def _render_EXT_ARRAY_type(self, type_, autogen_context): return render._render_type_w_subtype( - type_, autogen_context, 'item_type', r'(.+?\()', - prefix="custom_dialect_types." + type_, + autogen_context, + "item_type", + r"(.+?\()", + prefix="custom_dialect_types.", ) class EXT_ARRAY(sqla_types.TypeEngine): - __visit_name__ = 'EXT_ARRAY' + __visit_name__ = "EXT_ARRAY" def __init__(self, item_type): if isinstance(item_type, type): @@ -63,75 +69,78 @@ class EXT_ARRAY(sqla_types.TypeEngine): class FOOBARTYPE(sqla_types.TypeEngine): - __visit_name__ = 'FOOBARTYPE' + __visit_name__ = "FOOBARTYPE" class ExternalDialectRenderTest(TestBase): - def setUp(self): ctx_opts = { - 'sqlalchemy_module_prefix': 'sa.', - 'alembic_module_prefix': 'op.', - 'target_metadata': MetaData(), - 'user_module_prefix': None + "sqlalchemy_module_prefix": "sa.", + "alembic_module_prefix": "op.", + "target_metadata": MetaData(), + "user_module_prefix": None, } context = MigrationContext.configure( - dialect_name="custom_dialect", - opts=ctx_opts + dialect_name="custom_dialect", opts=ctx_opts ) self.autogen_context = api.AutogenContext(context) def test_render_type(self): eq_ignore_whitespace( - autogenerate.render._repr_type( - FOOBARTYPE(), self.autogen_context), - "custom_dialect_types.FOOBARTYPE()" + autogenerate.render._repr_type(FOOBARTYPE(), self.autogen_context), + "custom_dialect_types.FOOBARTYPE()", ) eq_( self.autogen_context.imports, - set([ - 'from tests.test_external_dialect import custom_dialect_types' - ]) + set( + [ + "from tests.test_external_dialect import custom_dialect_types" + ] + ), ) def test_external_nested_render_sqla_type(self): eq_ignore_whitespace( autogenerate.render._repr_type( - EXT_ARRAY(sqla_types.Integer), self.autogen_context), - "custom_dialect_types.EXT_ARRAY(sa.Integer())" + EXT_ARRAY(sqla_types.Integer), self.autogen_context + ), + "custom_dialect_types.EXT_ARRAY(sa.Integer())", ) eq_ignore_whitespace( autogenerate.render._repr_type( - EXT_ARRAY( - sqla_types.DateTime(timezone=True) - ), - self.autogen_context), - "custom_dialect_types.EXT_ARRAY(sa.DateTime(timezone=True))" + EXT_ARRAY(sqla_types.DateTime(timezone=True)), + self.autogen_context, + ), + "custom_dialect_types.EXT_ARRAY(sa.DateTime(timezone=True))", ) eq_( self.autogen_context.imports, - set([ - 'from tests.test_external_dialect import custom_dialect_types' - ]) + set( + [ + "from tests.test_external_dialect import custom_dialect_types" + ] + ), ) def test_external_nested_render_external_type(self): eq_ignore_whitespace( autogenerate.render._repr_type( - EXT_ARRAY(FOOBARTYPE), - self.autogen_context), - "custom_dialect_types.EXT_ARRAY(custom_dialect_types.FOOBARTYPE())" + EXT_ARRAY(FOOBARTYPE), self.autogen_context + ), + "custom_dialect_types.EXT_ARRAY(custom_dialect_types.FOOBARTYPE())", ) eq_( self.autogen_context.imports, - set([ - 'from tests.test_external_dialect import custom_dialect_types' - ]) + set( + [ + "from tests.test_external_dialect import custom_dialect_types" + ] + ), ) |