diff options
| author | Jon Dufresne <jon.dufresne@gmail.com> | 2016-06-27 09:13:15 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-06-27 12:17:34 -0400 |
| commit | 54c0dea22ee11da9822fc217f108e878647f299e (patch) | |
| tree | 007496ede6afc3954b9ef953baec47d1c7a186d1 | |
| parent | f40c91cdef74b81f731ad1582c26d0b60044dbc2 (diff) | |
[1.9.x] Refs #26034 -- Corrected a schema test to work with the correct field state.
Backport of d47f6d75ef67dbd18abf2bb927753f739a9c117d from master
| -rw-r--r-- | tests/schema/tests.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py index e200f34164..957d9cb9b1 100644 --- a/tests/schema/tests.py +++ b/tests/schema/tests.py @@ -1778,15 +1778,14 @@ class SchemaTests(TransactionTestCase): self.get_constraints_for_column(BookWithoutAuthor, 'title'), ['schema_book_d5d3db17', 'schema_book_title_2dfb2dff_like', 'schema_book_title_2dfb2dff_uniq'] ) - # Alter to remove unique=True (should drop unique index) # XXX: bug! - old_field = BookWithoutAuthor._meta.get_field('title') - new_field = CharField(max_length=100, db_index=True) - new_field.set_attributes_from_name('title') + # Alter to remove unique=True (should drop unique index) + new_field2 = CharField(max_length=100, db_index=True) + new_field2.set_attributes_from_name('title') with connection.schema_editor() as editor: - editor.alter_field(BookWithoutAuthor, old_field, new_field, strict=True) + editor.alter_field(BookWithoutAuthor, new_field, new_field2, strict=True) self.assertEqual( self.get_constraints_for_column(BookWithoutAuthor, 'title'), - ['schema_book_d5d3db17', 'schema_book_title_2dfb2dff_like', 'schema_book_title_2dfb2dff_uniq'] + ['schema_book_d5d3db17', 'schema_book_title_2dfb2dff_like'] ) @unittest.skipUnless(connection.vendor == 'postgresql', "PostgreSQL specific") @@ -1809,11 +1808,10 @@ class SchemaTests(TransactionTestCase): ['schema_tag_slug_2c418ba3_like', 'schema_tag_slug_key'] ) # Alter to remove db_index=True - old_field = Tag._meta.get_field('slug') - new_field = SlugField(unique=True) - new_field.set_attributes_from_name('slug') + new_field2 = SlugField(unique=True) + new_field2.set_attributes_from_name('slug') with connection.schema_editor() as editor: - editor.alter_field(Tag, old_field, new_field, strict=True) + editor.alter_field(Tag, new_field, new_field2, strict=True) self.assertEqual( self.get_constraints_for_column(Tag, 'slug'), ['schema_tag_slug_2c418ba3_like', 'schema_tag_slug_key'] |
