summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/plugin/plugin_base.py
diff options
context:
space:
mode:
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