summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2016-06-27 09:13:15 -0700
committerTim Graham <timograham@gmail.com>2016-06-27 12:13:15 -0400
commitd47f6d75ef67dbd18abf2bb927753f739a9c117d (patch)
tree4fc0e36a81ba1ed608d3a78fce670d61f508f5da
parent156e2d59cf92eb252c2f6ef9bb0b65f26c707de2 (diff)
Refs #26034 -- Corrected a schema test to work with the correct field state.
-rw-r--r--tests/schema/tests.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index a3e4f8227a..8cb119a3f9 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -1820,15 +1820,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")
@@ -1851,11 +1850,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']