diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index 7c21b58..03c5d79 100644
|
a
|
b
|
class SchemaTests(TransactionTestCase):
|
| 21 | 21 | available_apps = [] |
| 22 | 22 | |
| 23 | 23 | models = [Author, AuthorWithM2M, Book, BookWithSlug, BookWithM2M, Tag, TagIndexed, TagM2MTest, TagUniqueRename, UniqueTest] |
| 24 | | no_table_strings = ["no such table", "unknown table", "does not exist"] |
| 25 | 24 | |
| 26 | 25 | # Utility functions |
| 27 | 26 | |
| … |
… |
class SchemaTests(TransactionTestCase):
|
| 33 | 32 | "Deletes all model tables for our models for a clean test environment" |
| 34 | 33 | cursor = connection.cursor() |
| 35 | 34 | connection.disable_constraint_checking() |
| | 35 | table_names = connection.introspection.table_names(cursor) |
| 36 | 36 | for model in self.models: |
| 37 | 37 | # Remove any M2M tables first |
| 38 | 38 | for field in model._meta.local_many_to_many: |
| 39 | 39 | with atomic(): |
| 40 | | try: |
| | 40 | tbl = field.rel.through._meta.db_table |
| | 41 | if tbl in table_names: |
| 41 | 42 | cursor.execute(connection.schema_editor().sql_delete_table % { |
| 42 | | "table": connection.ops.quote_name(field.rel.through._meta.db_table), |
| | 43 | "table": connection.ops.quote_name(tbl), |
| 43 | 44 | }) |
| 44 | | except DatabaseError as e: |
| 45 | | if any(s in str(e).lower() for s in self.no_table_strings): |
| 46 | | pass |
| 47 | | else: |
| 48 | | raise |
| | 45 | table_names.remove(tbl) |
| 49 | 46 | # Then remove the main tables |
| 50 | 47 | with atomic(): |
| 51 | | try: |
| | 48 | tbl = model._meta.db_table |
| | 49 | if tbl in table_names: |
| 52 | 50 | cursor.execute(connection.schema_editor().sql_delete_table % { |
| 53 | | "table": connection.ops.quote_name(model._meta.db_table), |
| | 51 | "table": connection.ops.quote_name(tbl), |
| 54 | 52 | }) |
| 55 | | except DatabaseError as e: |
| 56 | | if any(s in str(e).lower() for s in self.no_table_strings): |
| 57 | | pass |
| 58 | | else: |
| 59 | | raise |
| | 53 | table_names.remove(tbl) |
| 60 | 54 | connection.enable_constraint_checking() |
| 61 | 55 | |
| 62 | 56 | def column_classes(self, model): |