diff options
Diffstat (limited to 'lib/sqlalchemy/testing')
| -rw-r--r-- | lib/sqlalchemy/testing/fixtures.py | 13 | ||||
| -rw-r--r-- | lib/sqlalchemy/testing/requirements.py | 25 |
2 files changed, 33 insertions, 5 deletions
diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py index e2237fb17..bc7a6120c 100644 --- a/lib/sqlalchemy/testing/fixtures.py +++ b/lib/sqlalchemy/testing/fixtures.py @@ -120,16 +120,11 @@ class TablesTest(TestBase): def _setup_each_tables(self): if self.run_define_tables == "each": - self.tables.clear() - if self.run_create_tables == "each": - drop_all_tables(self.metadata, self.bind) - self.metadata.clear() self.define_tables(self.metadata) if self.run_create_tables == "each": self.metadata.create_all(self.bind) self.tables.update(self.metadata.tables) elif self.run_create_tables == "each": - drop_all_tables(self.metadata, self.bind) self.metadata.create_all(self.bind) def _setup_each_inserts(self): @@ -138,6 +133,14 @@ class TablesTest(TestBase): self.insert_data() def _teardown_each_tables(self): + if self.run_define_tables == "each": + self.tables.clear() + if self.run_create_tables == "each": + drop_all_tables(self.metadata, self.bind) + self.metadata.clear() + elif self.run_create_tables == "each": + drop_all_tables(self.metadata, self.bind) + # no need to run deletes if tables are recreated on setup if self.run_define_tables != "each" and self.run_deletes == "each": with self.bind.connect() as conn: diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index 5b26ac72e..8bbb7ec45 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -431,6 +431,13 @@ class SuiteRequirements(Requirements): ) @property + def no_sequences(self): + """the oppopsite of "sequences", DB does not support sequences at + all.""" + + return exclusions.NotPredicate(self.sequences) + + @property def sequences_optional(self): """Target database supports sequences, but also optionally as a means of generating new PK values.""" @@ -444,6 +451,24 @@ class SuiteRequirements(Requirements): ) @property + def supports_lastrowid(self): + """target database / driver supports cursor.lastrowid as a means + of retrieving the last inserted primary key value. + + note that if the target DB supports sequences also, this is still + assumed to work. This is a new use case brought on by MariaDB 10.3. + + """ + return exclusions.only_if( + [lambda config: config.db.dialect.postfetch_lastrowid] + ) + + @property + def no_lastrowid_support(self): + """the opposite of supports_lastrowid""" + return exclusions.NotPredicate(self.supports_lastrowid) + + @property def reflects_pk_names(self): return exclusions.closed() |
