Improved test coverage of sequence module.
@@ -41,31 +41,43 @@ class SequenceTestCase(PersistenceSubscribingTestCase):
self.assertEqual(reader[-1], 'item3')
# Check slices also work.
- self.assertEqual(reader[0:], ['item1', 'item2', 'item3'])
- self.assertEqual(reader[-3:], ['item1', 'item2', 'item3'])
- self.assertEqual(reader[-4:], ['item1', 'item2', 'item3'])
self.assertEqual(reader[0:3], ['item1', 'item2', 'item3'])
self.assertEqual(reader[0:2], ['item1', 'item2'])
self.assertEqual(reader[0:-1], ['item1', 'item2'])
self.assertEqual(reader[0:1], ['item1'])
self.assertEqual(reader[0:-2], ['item1'])
- self.assertEqual(reader[1:], ['item2', 'item3'])
- self.assertEqual(reader[-2:], ['item2', 'item3'])
self.assertEqual(reader[1:3], ['item2', 'item3'])
self.assertEqual(reader[1:2], ['item2'])
self.assertEqual(reader[-2:-1], ['item2'])
self.assertEqual(reader[1:1], [])
self.assertEqual(reader[-2:-2], [])
- self.assertEqual(reader[2:], ['item3'])
- self.assertEqual(reader[-1:], ['item3'])
self.assertEqual(reader[2:3], ['item3'])
- self.assertEqual(reader[3:], [])
- self.assertEqual(reader[4:], [])
self.assertEqual(reader[3:3], [])
self.assertEqual(reader[0:300], ['item1', 'item2', 'item3'])
self.assertEqual(reader[2:1], [])
self.assertEqual(reader[2:-2], [])
+ self.assertEqual(reader[0:], ['item1', 'item2', 'item3'])
+ self.assertEqual(reader[1:], ['item2', 'item3'])
+ self.assertEqual(reader[2:], ['item3'])
+ self.assertEqual(reader[3:], [])
+ self.assertEqual(reader[4:], [])
+ self.assertEqual(reader[-1:], ['item3'])
+ self.assertEqual(reader[-2:], ['item2', 'item3'])
+ self.assertEqual(reader[-3:], ['item1', 'item2', 'item3'])
+ self.assertEqual(reader[-4:], ['item1', 'item2', 'item3'])
+
+ self.assertEqual(reader[:0], [])
+ self.assertEqual(reader[:1], ['item1'])
+ self.assertEqual(reader[:2], ['item1', 'item2'])
+ self.assertEqual(reader[:3], ['item1', 'item2', 'item3'])
+ self.assertEqual(reader[:4], ['item1', 'item2', 'item3'])
+ self.assertEqual(reader[:-1], ['item1', 'item2'])
+ self.assertEqual(reader[:-2], ['item1'])
+ self.assertEqual(reader[:-3], [])
+ self.assertEqual(reader[:-4], [])
+
+
# Check iterator.
for i, item in enumerate(reader):
self.assertEqual(item, 'item{}'.format(i + 1))
