diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2012-09-24 13:30:17 +0100 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2012-09-24 13:30:17 +0100 |
| commit | 15c1920964d2ff9a820986232cac11ae2dea048d (patch) | |
| tree | d59471c0ceed99c1e6dd39d1969edb4b15eabd8f | |
| parent | 0bcfc068b011c41aeed135649276106147d90d70 (diff) | |
Only swallow table-does-not-exist errors in tests
| -rw-r--r-- | tests/modeltests/schema/tests.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/modeltests/schema/tests.py b/tests/modeltests/schema/tests.py index 9818b0451c..f679624538 100644 --- a/tests/modeltests/schema/tests.py +++ b/tests/modeltests/schema/tests.py @@ -20,6 +20,7 @@ class SchemaTests(TestCase): """ models = [Author, AuthorWithM2M, Book, BookWithSlug, BookWithM2M, Tag, TagUniqueRename, UniqueTest] + no_table_strings = ["no such table", "unknown table", "does not exist"] # Utility functions @@ -57,8 +58,11 @@ class SchemaTests(TestCase): cursor.execute(connection.schema_editor().sql_delete_table % { "table": connection.ops.quote_name(field.rel.through._meta.db_table), }) - except DatabaseError: - connection.rollback() + except DatabaseError as e: + if any([s in str(e).lower() for s in self.no_table_strings]): + connection.rollback() + else: + raise else: connection.commit() # Then remove the main tables @@ -66,8 +70,11 @@ class SchemaTests(TestCase): cursor.execute(connection.schema_editor().sql_delete_table % { "table": connection.ops.quote_name(model._meta.db_table), }) - except DatabaseError: - connection.rollback() + except DatabaseError as e: + if any([s in str(e).lower() for s in self.no_table_strings]): + connection.rollback() + else: + raise else: connection.commit() connection.enable_constraint_checking() |
