summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/migrations/operations/models.py8
-rw-r--r--tests/migrations/test_operations.py20
2 files changed, 15 insertions, 13 deletions
diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py
index 9526876da2..5fa9addb12 100644
--- a/django/db/migrations/operations/models.py
+++ b/django/db/migrations/operations/models.py
@@ -17,7 +17,7 @@ def _check_for_duplicates(arg_name, objs):
for val in objs:
if val in used_vals:
raise ValueError(
- 'Found duplicate %s in CreateModel operation.' % arg_name
+ "Found duplicate value %s in CreateModel %s argument." % (val, arg_name)
)
used_vals.add(val)
@@ -55,14 +55,14 @@ class CreateModel(ModelOperation):
super(CreateModel, self).__init__(name)
# Sanity-check that there are no duplicated field names, bases, or
# manager names
- _check_for_duplicates("field", (name for name, _ in self.fields))
+ _check_for_duplicates('fields', (name for name, _ in self.fields))
_check_for_duplicates(
- "base",
+ 'bases',
(base._meta.label_lower if isinstance(base, models.base.ModelBase) else base.lower()
for base in self.bases
if base is not models.Model)
)
- _check_for_duplicates("manager", (name for name, _ in self.managers))
+ _check_for_duplicates('managers', (name for name, _ in self.managers))
def deconstruct(self):
kwargs = {
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index 2df12fed8f..d34a6a4284 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -201,7 +201,7 @@ class OperationTests(OperationTestBase):
self.assertNotIn('managers', definition[2])
def test_create_model_with_duplicate_field_name(self):
- with self.assertRaisesMessage(ValueError, "Found duplicate field in CreateModel operation."):
+ with self.assertRaisesMessage(ValueError, 'Found duplicate value pink in CreateModel fields argument.'):
migrations.CreateModel(
"Pony",
[
@@ -212,31 +212,33 @@ class OperationTests(OperationTestBase):
)
def test_create_model_with_duplicate_base(self):
- with self.assertRaisesMessage(ValueError, "Found duplicate base in CreateModel operation."):
+ message = 'Found duplicate value test_crmo.pony in CreateModel bases argument.'
+ with self.assertRaisesMessage(ValueError, message):
migrations.CreateModel(
"Pony",
fields=[],
bases=("test_crmo.Pony", "test_crmo.Pony",),
)
- with self.assertRaisesMessage(ValueError, "Found duplicate base in CreateModel operation."):
+ with self.assertRaisesMessage(ValueError, message):
migrations.CreateModel(
"Pony",
fields=[],
- bases=(UnicodeModel, UnicodeModel,),
+ bases=("test_crmo.Pony", "test_crmo.pony",),
)
- with self.assertRaisesMessage(ValueError, "Found duplicate base in CreateModel operation."):
+ message = 'Found duplicate value migrations.unicodemodel in CreateModel bases argument.'
+ with self.assertRaisesMessage(ValueError, message):
migrations.CreateModel(
"Pony",
fields=[],
- bases=("test_crmo.Pony", "test_crmo.pony",),
+ bases=(UnicodeModel, UnicodeModel,),
)
- with self.assertRaisesMessage(ValueError, "Found duplicate base in CreateModel operation."):
+ with self.assertRaisesMessage(ValueError, message):
migrations.CreateModel(
"Pony",
fields=[],
bases=(UnicodeModel, 'migrations.unicodemodel',),
)
- with self.assertRaisesMessage(ValueError, "Found duplicate base in CreateModel operation."):
+ with self.assertRaisesMessage(ValueError, message):
migrations.CreateModel(
"Pony",
fields=[],
@@ -244,7 +246,7 @@ class OperationTests(OperationTestBase):
)
def test_create_model_with_duplicate_manager_name(self):
- with self.assertRaisesMessage(ValueError, "Found duplicate manager in CreateModel operation."):
+ with self.assertRaisesMessage(ValueError, 'Found duplicate value objects in CreateModel managers argument.'):
migrations.CreateModel(
"Pony",
fields=[],