diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-10-21 17:32:04 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2019-10-22 18:27:48 -0400 |
| commit | 240d9a60ccdb540543a72d9ff30a6f50d33acc5d (patch) | |
| tree | ff665f4c9a1e7dac8311732bf8ecc1a370a388fc /lib/sqlalchemy/testing/util.py | |
| parent | d76cb7213557c24609a1a75d8c391aea0179562a (diff) | |
| download | sqlalchemy-240d9a60ccdb540543a72d9ff30a6f50d33acc5d.tar.gz | |
Refactor dialect tests for combinations
Dialect tests tend to have a lot of lists of types,
SQL constructs etc, convert as many of these to @combinations
as possible.
This is exposing that we don't have per-combination
exclusion rules set up which is making things a little bit
cumbersome.
Also set up a fixture that does metadata + DDL.
Change-Id: Ief820e48c9202982b0b1e181b87862490cd7b0c3
Diffstat (limited to 'lib/sqlalchemy/testing/util.py')
| -rw-r--r-- | lib/sqlalchemy/testing/util.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/util.py b/lib/sqlalchemy/testing/util.py index 219511ea0..64738ad2f 100644 --- a/lib/sqlalchemy/testing/util.py +++ b/lib/sqlalchemy/testing/util.py @@ -211,6 +211,30 @@ def provide_metadata(fn, *args, **kw): self.metadata = prev_meta +def metadata_fixture(ddl="function"): + """Provide MetaData for a pytest fixture.""" + + from . import config + + def decorate(fn): + def run_ddl(self): + from sqlalchemy import schema + + metadata = self.metadata = schema.MetaData() + try: + result = fn(self, metadata) + metadata.create_all(config.db) + # TODO: + # somehow get a per-function dml erase fixture here + yield result + finally: + metadata.drop_all(config.db) + + return config.fixture(scope=ddl)(run_ddl) + + return decorate + + def force_drop_names(*names): """Force the given table names to be dropped after test complete, isolating for foreign key cycles |
