MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_slice

Method test_slice

Lib/test/test_array.py:1761–1776  ·  view source on GitHub ↗
(self, size)

Source from the content-addressed store, hash-verified

1759
1760 @support.bigmemtest(_2G, memuse=2.125+1)
1761 def test_slice(self, size):
1762 example = self.example(size)
1763 self.assertEqual(list(example[:4]), [0, 1, 2, 3])
1764 self.assertEqual(list(example[-4:]), [8, 9, 10, 11])
1765 part = example[1:-1]
1766 self.assertEqual(len(part), size+2)
1767 self.assertEqual(part[0], 1)
1768 self.assertEqual(part[-1], 10)
1769 del part
1770 part = example[::2]
1771 self.assertEqual(len(part), (size+5)//2)
1772 self.assertEqual(list(part[:4]), [0, 2, 4, 6])
1773 if size % 2:
1774 self.assertEqual(list(part[-2:]), [9, 11])
1775 else:
1776 self.assertEqual(list(part[-2:]), [8, 10])
1777
1778 @support.bigmemtest(_2G, memuse=2.125)
1779 def test_count(self, size):

Callers

nothing calls this directly

Calls 4

exampleMethod · 0.95
listClass · 0.85
lenFunction · 0.85
assertEqualMethod · 0.45

Tested by

no test coverage detected