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))
|
% str(self._document))
|
||||||
raise OperationError(msg)
|
raise OperationError(msg)
|
||||||
if doc.pk and not doc._created:
|
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)
|
raise OperationError(msg)
|
||||||
|
|
||||||
signal_kwargs = signal_kwargs or {}
|
signal_kwargs = signal_kwargs or {}
|
||||||
|
@ -898,13 +898,19 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
with self.assertRaises(OperationError) as cm:
|
with self.assertRaises(OperationError) as cm:
|
||||||
blog = Blog.objects.first()
|
blog = Blog.objects.first()
|
||||||
Blog.objects.insert(blog)
|
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
|
# test inserting a query set
|
||||||
with self.assertRaises(OperationError) as cm:
|
with self.assertRaises(OperationError) as cm:
|
||||||
blogs_qs = Blog.objects
|
blogs_qs = Blog.objects
|
||||||
Blog.objects.insert(blogs_qs)
|
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
|
# insert 1 new doc
|
||||||
new_post = Blog(title="code123", id=ObjectId())
|
new_post = Blog(title="code123", id=ObjectId())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user