Ejemplo n.º 1
0
def test_rejects_invalid_args():

    try: 
        bottom_up(Dir('A'), None)
        assert False, 'Invalid tool.'
    except:
        pass

    try:
        bottom_up(None, lambda x: x)
        assert False, 'Invalid tool.'
    except:
        pass
Ejemplo n.º 2
0
def test_bottom_up():
    d1 = Dir('A')
    d2 = Dir('B')
    d3 = Dir('C')
    d4 = Dir('D')

    d3.parent = d2
    d4.parent = d2
    d2.parent = d1

    order = []
    def tool(item):
        order.append(item.name)

    bottom_up(d1, tool)

    assert order == ['C', 'D', 'B', 'A'], str(order)