def make_page(self, width, nentries, include_entry=None): if include_entry: assert len(include_entry) == width, (include_entry, width) entries = [make_page_entry(width) for _ in range(nentries)] if include_entry: entries += [include_entry] for entry in sorted(entries): print(entry) return SearchPage(b''.join(sorted(entries)), *((18, 0) if width == 18 else (18, 20)))
def test_setitem3(self): page = SearchPage(b'abcd', 1, 1) page[b'X'] = b'x' self.assertEqual(page.data, b'Xxabcd')
def test_setitem21(self): page = SearchPage(b'abcdef', 1, 1) page[b'd'] = b'x' self.assertEqual(page.data, b'abcddxef')
def test_getitem2(self): page = SearchPage(b'abcd', 1, 1) with self.assertRaises(KeyError): x = page[b'd'] self.assertEqual(page[b'a'], b'b')
def test_delitem5(self): page = SearchPage(b'x11y22z33', 1, 2) del page[b'z'] self.assertEqual(page.data, b'x11y22')
def test_delitem2(self): page = SearchPage(b'x11', 1, 2) del page[b'x'] self.assertEqual(page.data, b'')
def test_delitem1(self): page = SearchPage(b'', 1, 2) with self.assertRaises(KeyError): del page[b'x'] self.assertEqual(page.data, b'')
def test_setitem8(self): page = SearchPage(b'', 1, 0) page[b'X'] = b'' self.assertEqual(page.data, b'X')
def test_setitem6(self): page = SearchPage(b'abcd', 1, 0) page[b'e'] = b'' self.assertEqual(page.data, b'abcde')