def test_paged_list(self):

    def testPL(size, pagesize, sliceargs, expected):

        def get_page(pagenum):
            firstid = (pagenum * pagesize)
            upto = min(size, ((pagenum * pagesize) + pagesize))
            (yield from range(firstid, upto))
        pl = OnDemandPagedList(get_page, pagesize)
        got = pl.getslice(*sliceargs)
        self.assertEqual(got, expected)
        iapl = InAdvancePagedList(get_page, ((size // pagesize) + 1), pagesize)
        got = iapl.getslice(*sliceargs)
        self.assertEqual(got, expected)
    testPL(5, 2, (), [0, 1, 2, 3, 4])
    testPL(5, 2, (1,), [1, 2, 3, 4])
    testPL(5, 2, (2,), [2, 3, 4])
    testPL(5, 2, (4,), [4])
    testPL(5, 2, (0, 3), [0, 1, 2])
    testPL(5, 2, (1, 4), [1, 2, 3])
    testPL(5, 2, (2, 99), [2, 3, 4])
    testPL(5, 2, (20, 99), [])
def test_paged_list(self):

    def testPL(size, pagesize, sliceargs, expected):

        def get_page(pagenum):
            firstid = (pagenum * pagesize)
            upto = min(size, ((pagenum * pagesize) + pagesize))
            (yield from range(firstid, upto))
        pl = OnDemandPagedList(get_page, pagesize)
        got = pl.getslice(*sliceargs)
        self.assertEqual(got, expected)
        iapl = InAdvancePagedList(get_page, ((size // pagesize) + 1), pagesize)
        got = iapl.getslice(*sliceargs)
        self.assertEqual(got, expected)
    testPL(5, 2, (), [0, 1, 2, 3, 4])
    testPL(5, 2, (1,), [1, 2, 3, 4])
    testPL(5, 2, (2,), [2, 3, 4])
    testPL(5, 2, (4,), [4])
    testPL(5, 2, (0, 3), [0, 1, 2])
    testPL(5, 2, (1, 4), [1, 2, 3])
    testPL(5, 2, (2, 99), [2, 3, 4])
    testPL(5, 2, (20, 99), [])