Fix wording of an exception message in QuerySet.insert
This commit is contained in:
parent
1f02d5fbbd
commit
996618a495
@ -335,7 +335,7 @@ class BaseQuerySet(object):
|
||||
% str(self._document))
|
||||
raise OperationError(msg)
|
||||
if doc.pk and not doc._created:
|
||||
msg = 'Some documents have ObjectIds use doc.update() instead'
|
||||
msg = 'Some documents have ObjectIds, use doc.update() instead'
|
||||
raise OperationError(msg)
|
||||
|
||||
signal_kwargs = signal_kwargs or {}
|
||||
|
@ -898,13 +898,19 @@ class QuerySetTest(unittest.TestCase):
|
||||
with self.assertRaises(OperationError) as cm:
|
||||
blog = Blog.objects.first()
|
||||
Blog.objects.insert(blog)
|
||||
self.assertEqual(str(cm.exception), 'Some documents have ObjectIds use doc.update() instead')
|
||||
self.assertEqual(
|
||||
str(cm.exception),
|
||||
'Some documents have ObjectIds, use doc.update() instead'
|
||||
)
|
||||
|
||||
# test inserting a query set
|
||||
with self.assertRaises(OperationError) as cm:
|
||||
blogs_qs = Blog.objects
|
||||
Blog.objects.insert(blogs_qs)
|
||||
self.assertEqual(str(cm.exception), 'Some documents have ObjectIds use doc.update() instead')
|
||||
self.assertEqual(
|
||||
str(cm.exception),
|
||||
'Some documents have ObjectIds, use doc.update() instead'
|
||||
)
|
||||
|
||||
# insert 1 new doc
|
||||
new_post = Blog(title="code123", id=ObjectId())
|
||||
|
Loading…
x
Reference in New Issue
Block a user