def test_reversed_frees_empty(self):
    import gc
    for typ in (list, unicode):
        free = [False]

        class U(typ):

            def __del__(self):
                free[0] = True
        r = reversed(U())
        raises(StopIteration, next, r)
        gc.collect()
        gc.collect()
        gc.collect()
        assert free[0]
def test_reversed_frees_empty(self):
    import gc
    for typ in (list, unicode):
        free = [False]

        class U(typ):

            def __del__(self):
                free[0] = True
        r = reversed(U())
        raises(StopIteration, next, r)
        gc.collect()
        gc.collect()
        gc.collect()
        assert free[0]