summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2017-06-30 08:35:58 -0400
committerSimon Charette <charette.s@gmail.com>2017-06-30 13:12:33 -0400
commitc1621d80089cb3e77c8a504310feeb24fea61afe (patch)
tree35d0cbcf6070be1af5e1c1a7b3eea29b133fb2a1 /tests
parenta6756195c1a11eee10c16c96fe95d52e22e1d9ba (diff)
[1.11.x] Fixed #28350 -- Fixed UnboundLocalError crash in RenameField with nonexistent field.
Thanks Tim for the review. Backport of 5cbcb3683964205ce023157ca181d05a31be2ab5 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_operations.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 3b2bd8275c..64ae395d94 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
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
@@ -1370,6 +1371,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.