summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/plugin/plugin_base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-12-21 10:22:43 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-01-03 13:22:29 -0500
commitfd3c063dd68b289814af724689165418de5e4408 (patch)
tree3a13c1cd3bd58b8b5b88bc3294e491aca63ecf0b /lib/sqlalchemy/testing/plugin/plugin_base.py
parentdd41a5e61a30a2d05ee09f583fdfde1f1c204807 (diff)
downloadsqlalchemy-fd3c063dd68b289814af724689165418de5e4408.tar.gz
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
Diffstat (limited to 'lib/sqlalchemy/testing/plugin/plugin_base.py')
-rw-r--r--lib/sqlalchemy/testing/plugin/plugin_base.py68
1 files changed, 4 insertions, 64 deletions
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