test negative indexes (closes #1119)
This commit is contained in:
parent
19ef2be88b
commit
e8ea294964
@ -1173,6 +1173,14 @@ class FieldTest(MongoDBTestCase):
|
|||||||
post.reload()
|
post.reload()
|
||||||
self.assertEqual(post.info, ['0', '1', '2', '3', 'a', '5'])
|
self.assertEqual(post.info, ['0', '1', '2', '3', 'a', '5'])
|
||||||
|
|
||||||
|
# __setitem__(index, value) with a negative index
|
||||||
|
reset_post()
|
||||||
|
post.info[-2] = 'a'
|
||||||
|
self.assertEqual(post.info, ['0', '1', '2', '3', 'a', '5'])
|
||||||
|
post.save()
|
||||||
|
post.reload()
|
||||||
|
self.assertEqual(post.info, ['0', '1', '2', '3', 'a', '5'])
|
||||||
|
|
||||||
# '__setitem__(slice(i, j), listB)'
|
# '__setitem__(slice(i, j), listB)'
|
||||||
# aka 'listA[i:j] = listB'
|
# aka 'listA[i:j] = listB'
|
||||||
# aka 'setitem(listA, slice(i, j), listB)'
|
# aka 'setitem(listA, slice(i, j), listB)'
|
||||||
@ -1183,6 +1191,16 @@ class FieldTest(MongoDBTestCase):
|
|||||||
post.reload()
|
post.reload()
|
||||||
self.assertEqual(post.info, ['0', 'h', 'e', 'l', 'l', 'o', '3', '4', '5'])
|
self.assertEqual(post.info, ['0', 'h', 'e', 'l', 'l', 'o', '3', '4', '5'])
|
||||||
|
|
||||||
|
# '__setitem__(slice(i, j), listB)' with negative i and j
|
||||||
|
reset_post()
|
||||||
|
post.info[-5:-3] = ['h', 'e', 'l', 'l', 'o']
|
||||||
|
self.assertEqual(post.info, ['0', 'h', 'e', 'l', 'l', 'o', '3', '4', '5'])
|
||||||
|
post.save()
|
||||||
|
post.reload()
|
||||||
|
self.assertEqual(post.info, ['0', 'h', 'e', 'l', 'l', 'o', '3', '4', '5'])
|
||||||
|
|
||||||
|
# negative
|
||||||
|
|
||||||
# 'append'
|
# 'append'
|
||||||
reset_post()
|
reset_post()
|
||||||
post.info.append('h')
|
post.info.append('h')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user