diff options
| author | Simon Charette <charette.s@gmail.com> | 2017-06-30 08:35:58 -0400 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2017-06-30 12:50:37 -0400 |
| commit | 5cbcb3683964205ce023157ca181d05a31be2ab5 (patch) | |
| tree | 9e5e6a3a8c9d4bb6258b2878f2fb26bd61fcc35a /tests | |
| parent | b9f7dce84b7ab5e198129030eae6c1a4aec83d24 (diff) | |
Fixed #28350 -- Fixed UnboundLocalError crash in RenameField with nonexistent field.
Thanks Tim for the review.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/migrations/test_operations.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py index f0d24443a4..ec55ab912e 100644 --- a/tests/migrations/test_operations.py +++ b/tests/migrations/test_operations.py @@ -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. |
