def testExceededChunksLimit(self): buffer_size = 10 data = xrange(MAX_CHUNKS * buffer_size + 1) self.assertTrue(sort(data), "Creating iterator wont raise error") with self.assertRaises(MemoryError): list(sort(data, buffer_size=buffer_size))
def testTenKRepeatingData(self): data = [i % 100 for i in range(10000)] expected_data = sorted(data) self.assertListEqual(expected_data, list(sort(data)))
def testDifferentKey(self): assert list(reversed(DATA_SORTED)) == list(sort(DATA, key=lambda i: -i)) self.assertListEqual(DATA_STRINGS_SORTED_ON_LEN, list(sort(DATA_STRINGS, key=lambda s: len(s))))
def testLargerBuffer(self): self.assertListEqual(DATA_SORTED, list(sort(DATA, buffer_size=len(DATA) + 10)))
def testSmallerBuffer(self): self.assertListEqual(DATA_SORTED, list(sort(DATA, buffer_size=3))) self.assertListEqual(DATA_SORTED, list(sort(DATA, buffer_size=len(DATA) - 1)))
def testBasic(self): self.assertListEqual(DATA_SORTED, list(sort(DATA, buffer_size=len(DATA))))