mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #28350 -- Fixed UnboundLocalError crash in RenameField with nonexistent field.
Thanks Tim for the review.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import unittest
|
||||
|
||||
from django.core.exceptions import FieldDoesNotExist
|
||||
from django.db import connection, migrations, models, transaction
|
||||
from django.db.migrations.migration import Migration
|
||||
from django.db.migrations.operations import CreateModel
|
||||
@@ -1368,6 +1369,12 @@ class OperationTests(OperationTestBase):
|
||||
self.assertEqual(definition[1], [])
|
||||
self.assertEqual(definition[2], {'model_name': "Pony", 'old_name': "pink", 'new_name': "blue"})
|
||||
|
||||
def test_rename_missing_field(self):
|
||||
state = ProjectState()
|
||||
state.add_model(ModelState('app', 'model', []))
|
||||
with self.assertRaisesMessage(FieldDoesNotExist, "app.model has no field named 'field'"):
|
||||
migrations.RenameField('model', 'field', 'new_field').state_forwards('app', state)
|
||||
|
||||
def test_alter_unique_together(self):
|
||||
"""
|
||||
Tests the AlterUniqueTogether operation.
|
||||
|
||||
Reference in New Issue
Block a user