Ticket #24595: 24595-test.diff

File 24595-test.diff, 1.1 KB (added by Claude Paroz, 10 years ago)

test failure

  • tests/schema/tests.py

    diff --git a/tests/schema/tests.py b/tests/schema/tests.py
    index f6b80b9..fc2c568 100644
    a b class SchemaTests(TransactionTestCase):  
    426426        with connection.schema_editor() as editor:
    427427            editor.alter_field(Note, old_field, new_field, strict=True)
    428428
     429    def test_alter_field_keep_null_status(self):
     430        """
     431        Changing a field type shouldn't affect the not null status.
     432        """
     433        with connection.schema_editor() as editor:
     434            editor.create_model(Note)
     435        with self.assertRaises(IntegrityError):
     436            Note.objects.create(info=None)
     437        old_field = Note._meta.get_field("info")
     438        new_field = CharField(max_length=50)
     439        new_field.set_attributes_from_name("info")
     440        with connection.schema_editor() as editor:
     441            editor.alter_field(Note, old_field, new_field, strict=True)
     442        with self.assertRaises(IntegrityError):
     443            Note.objects.create(info=None)
     444
    429445    def test_alter_null_to_not_null(self):
    430446        """
    431447        #23609 - Tests handling of default values when altering from NULL to NOT NULL.
Back to Top