Ticket #33256: 33256-init.diff

File 33256-init.diff, 1.6 KB (added by Tim Graham, 3 years ago)
  • tests/schema/tests.py

    diff --git a/tests/schema/tests.py b/tests/schema/tests.py
    index b8ad08239b..90440ca734 100644
    a b class SchemaTests(TransactionTestCase):  
    19801980                # This fails if the unique index name isn't quoted.
    19811981                editor.alter_unique_together(TagUniqueRename, [], (('title', 'slug2'),))
    19821982        finally:
     1983            if TagUniqueRename._meta.db_table == 'unique-table':
     1984                with connection.schema_editor() as editor:
     1985                    editor.delete_model(TagUniqueRename)
    19831986            TagUniqueRename._meta.db_table = old_table_name
    19841987
    19851988    @isolate_apps('schema')
    class SchemaTests(TransactionTestCase):  
    32363239    def test_add_foreign_object(self):
    32373240        with connection.schema_editor() as editor:
    32383241            editor.create_model(BookForeignObj)
    3239 
    3240         new_field = ForeignObject(Author, on_delete=CASCADE, from_fields=['author_id'], to_fields=['id'])
    3241         new_field.set_attributes_from_name('author')
    3242         with connection.schema_editor() as editor:
    3243             editor.add_field(BookForeignObj, new_field)
     3242        try:
     3243            new_field = ForeignObject(Author, on_delete=CASCADE, from_fields=['author_id'], to_fields=['id'])
     3244            new_field.set_attributes_from_name('author')
     3245            with connection.schema_editor() as editor:
     3246                editor.add_field(BookForeignObj, new_field)
     3247        finally:
     3248            # Clean up the table
     3249            with connection.schema_editor() as editor:
     3250                editor.delete_model(BookForeignObj)
    32443251
    32453252    def test_creation_deletion_reserved_names(self):
    32463253        """
Back to Top