You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changing the tests like shown below fails with error
File "[...]/tests/fields.py", line 38, in test_sorted_list_sorting
post.save()
File "[...]\document.py", line 183, in save
doc = self.to_mongo()
File "[...]\base.py", line 956, in to_mongo
data[field.db_field] = field.to_mongo(value)
File "[...]\fields.py", line 538, in to_mongo
return sorted(value, key=itemgetter(self._ordering), reverse=self._order_reverse)
TypeError: 'DBRef' object is not subscriptable
def test_sorted_list_sorting(self):
"""Ensure that a sorted list field properly sorts values.
"""
class Comment(Document):
order = IntField()
content = StringField()
class BlogPost(Document):
content = StringField()
comments = SortedListField(ReferenceField(Comment),
ordering='order')
tags = SortedListField(StringField())
post = BlogPost(content='Went for a walk today...')
post.save()
post.tags = ['leisure', 'fun']
post.save()
post.reload()
self.assertEqual(post.tags, ['fun', 'leisure'])
comment1 = Comment(content='Good for you', order=1)
comment1.save()
comment2 = Comment(content='Yay.', order=0)
comment2.save()
comments = [comment1, comment2]
post.comments = comments
post.save()
post.reload()
self.assertEqual(post.comments[0].content, comment2.content)
self.assertEqual(post.comments[1].content, comment1.content)
BlogPost.drop_collection()
The text was updated successfully, but these errors were encountered:
Changing the tests like shown below fails with error
File "[...]/tests/fields.py", line 38, in test_sorted_list_sorting
post.save()
File "[...]\document.py", line 183, in save
doc = self.to_mongo()
File "[...]\base.py", line 956, in to_mongo
data[field.db_field] = field.to_mongo(value)
File "[...]\fields.py", line 538, in to_mongo
return sorted(value, key=itemgetter(self._ordering), reverse=self._order_reverse)
TypeError: 'DBRef' object is not subscriptable
The text was updated successfully, but these errors were encountered: