From fd3c063dd68b289814af724689165418de5e4408 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 21 Dec 2020 10:22:43 -0500 Subject: remove metadata.bind use from test suite importantly this means we can remove bound metadata from the fixtures that are used by Alembic's test suite. hopefully this is the last one that has to happen to allow Alembic to be fully 1.4/2.0. Start moving from @testing.provide_metadata to a pytest metadata fixture. This does not seem to have any negative effects even though TablesTest uses a "self.metadata" attribute. Change-Id: Iae6ab95938a7e92b6d42086aec534af27b5577d3 --- lib/sqlalchemy/testing/plugin/plugin_base.py | 68 ++-------------------------- 1 file changed, 4 insertions(+), 64 deletions(-) (limited to 'lib/sqlalchemy/testing/plugin/plugin_base.py') diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index 8b6a7d68a..d200b262e 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -461,73 +461,13 @@ def _setup_requirements(argument): @post def _prep_testing_database(options, file_config): - from sqlalchemy.testing import config, util - from sqlalchemy.testing.exclusions import against - from sqlalchemy import schema, inspect + from sqlalchemy.testing import config if options.dropfirst: - for cfg in config.Config.all_configs(): - e = cfg.db - - # TODO: this has to be part of provision.py in postgresql - if against(cfg, "postgresql"): - with e.connect().execution_options( - isolation_level="AUTOCOMMIT" - ) as conn: - for xid in conn.execute( - "select gid from pg_prepared_xacts" - ).scalars(): - conn.execute("ROLLBACK PREPARED '%s'" % xid) - - inspector = inspect(e) - try: - view_names = inspector.get_view_names() - except NotImplementedError: - pass - else: - for vname in view_names: - e.execute( - schema._DropView( - schema.Table(vname, schema.MetaData()) - ) - ) + from sqlalchemy.testing import provision - if config.requirements.schemas.enabled_for_config(cfg): - try: - view_names = inspector.get_view_names(schema="test_schema") - except NotImplementedError: - pass - else: - for vname in view_names: - e.execute( - schema._DropView( - schema.Table( - vname, - schema.MetaData(), - schema="test_schema", - ) - ) - ) - - util.drop_all_tables(e, inspector) - - if config.requirements.schemas.enabled_for_config(cfg): - util.drop_all_tables(e, inspector, schema=cfg.test_schema) - - # TODO: this has to be part of provision.py in postgresql - if against(cfg, "postgresql"): - from sqlalchemy.dialects import postgresql - - for enum in inspector.get_enums("*"): - e.execute( - postgresql.DropEnumType( - postgresql.ENUM( - name=enum["name"], schema=enum["schema"] - ) - ) - ) - - # TODO: need to do a get_sequences and drop them also after tables + for cfg in config.Config.all_configs(): + provision.drop_all_schema_objects(cfg, cfg.db) @post -- cgit v1.2.1