def testfrom_iter_basic(self): for n in [0, 1, 10, 100, 1000, 10000]: a = xrange(n) self.assertRaises(AttributeError, avl.from_iter, a, len(a) + 1) self.assertRaises(StopIteration, avl.from_iter, iter(a), len(a) + 1) for n in [0, 1, 10, 100, 1000, 10000, 100000]: a = xrange(n) t = avl.from_iter(iter(a), len(a)) self.assert_(verify_len(t, n)) for j, k in gen_iter(iter(a), iter(t)): self.assert_(j == k)
def __setstate__(self, state): l, key = state self._set_key(key) self._avl = avl.from_iter(iter(l), len(l))
def __setstate__(self, state): l, key = state self._set_key(key) self._avl = avl.from_iter(iter(l), len(l))
def testfrom_iter_compare(self): a = self.list1 + map(lambda s: string.lower(s), self.list1) t = avl.new(a, unique=0, compare=revlowercmp) u = avl.from_iter(iter(t), len(t), compare=revlowercmp) self.assert_(u.verify() == 1)