def test_iter_exclusive(self): io = self.make_fp() self.assertEqual([2]*10, map(int, sortedfile.iter_exclusive(io, 1, 3, key=int))) self.assertEqual([], list(sortedfile.iter_inclusive(io, 99, 100, key=int))) self.assertEqual([], list(sortedfile.iter_inclusive(io, 0, 0.5, key=int)))
def test_iter_exclusive(self): io = self.make_fp() self.assertEqual([2] * 10, map(int, sortedfile.iter_exclusive(io, 1, 3, key=int))) self.assertEqual([], list(sortedfile.iter_inclusive(io, 99, 100, key=int))) self.assertEqual([], list(sortedfile.iter_inclusive(io, 0, 0.5, key=int)))
def test_zu2(self): def parse_time(s): return time.strptime(s, '%m/%d/%Y %H%M') def key_func(s): time_s = ' '.join(s.split(',', 3)[:2]) return parse_time(time_s) io = StringIO.StringIO(ZU2) sortedfile.bisect_seek_left(io, parse_time('10/01/2004 0952'), key=key_func) self.assertEqual([], list(io)) it = sortedfile.iter_inclusive(io, x=parse_time('09/30/2002 0328'), y=parse_time('09/30/2002 0332'), key=key_func) self.assertEqual(5, len(list(it)))