def test_grid1(capsys): grid = [[4],[20]] print_paths(grid) captured = capsys.readouterr() out = captured.out.strip().split('\n') correct = ['[4, 20]'] assert len(out) == len(correct) and set(out) == set(correct)
def test_grid3(capsys): grid = [[1,20,30], [4,8,40]] print_paths(grid) captured = capsys.readouterr() out = captured.out.strip().split('\n') correct = ['[1, 20, 30, 40]', '[1, 4, 8, 40]', '[1, 4, 8, 20, 30, 40]'] assert len(out) == len(correct) and set(out) == set(correct)
def test_grid2(capsys): grid = [[1,4,3], [5,6,7]] print_paths(grid) captured = capsys.readouterr() out = captured.out.strip().split('\n') correct = ['[1, 5, 6, 7]', '[1, 4, 6, 7]', ] assert len(out) == len(correct) and set(out) == set(correct)
def test_grid4(capsys): grid = [[1, 2, 3], [3, 6, 7], [8, 10, 8], [9,11,13]] print_paths(grid) captured = capsys.readouterr() out = captured.out.strip().split('\n') correct = ['[1, 2, 3, 7, 8, 10, 11, 13]', '[1, 2, 3, 7, 8, 13]', '[1, 2, 6, 7, 8, 10, 11, 13]', '[1, 2, 6, 7, 8, 13]', '[1, 2, 6, 10, 11, 13]', '[1, 3, 6, 7, 8, 10, 11, 13]', '[1, 3, 6, 7, 8, 13]', '[1, 3, 6, 10, 11, 13]', '[1, 3, 8, 10, 11, 13]', '[1, 3, 8, 9, 11, 13]'] assert len(out) == len(correct) and set(out) == set(correct)
def test_grid5(capsys): grid = [[1, 5, 6, 7], [11, 10, 9, 8], [12,13,14,15], [16,17,18,19]] print_paths(grid) captured = capsys.readouterr() out = captured.out.strip().split('\n') correct = ['[1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 19]', '[1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 18, 19]', '[1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 17, 18, 19]', '[1, 5, 6, 7, 8, 9, 10, 11, 12, 16, 17, 18, 19]', '[1, 5, 6, 7, 8, 9, 10, 13, 14, 15, 19]', '[1, 5, 6, 7, 8, 9, 10, 13, 14, 18, 19]', '[1, 5, 6, 7, 8, 9, 10, 13, 17, 18, 19]', '[1, 5, 6, 7, 8, 9, 14, 15, 19]', '[1, 5, 6, 7, 8, 9, 14, 18, 19]', '[1, 5, 6, 7, 8, 15, 19]', '[1, 5, 6, 9, 10, 11, 12, 13, 14, 15, 19]', '[1, 5, 6, 9, 10, 11, 12, 13, 14, 18, 19]', '[1, 5, 6, 9, 10, 11, 12, 13, 17, 18, 19]', '[1, 5, 6, 9, 10, 11, 12, 16, 17, 18, 19]', '[1, 5, 6, 9, 10, 13, 14, 15, 19]', '[1, 5, 6, 9, 10, 13, 14, 18, 19]', '[1, 5, 6, 9, 10, 13, 17, 18, 19]', '[1, 5, 6, 9, 14, 15, 19]', '[1, 5, 6, 9, 14, 18, 19]', '[1, 5, 10, 11, 12, 13, 14, 15, 19]', '[1, 5, 10, 11, 12, 13, 14, 18, 19]', '[1, 5, 10, 11, 12, 13, 17, 18, 19]', '[1, 5, 10, 11, 12, 16, 17, 18, 19]', '[1, 5, 10, 13, 14, 15, 19]', '[1, 5, 10, 13, 14, 18, 19]', '[1, 5, 10, 13, 17, 18, 19]', '[1, 11, 12, 13, 14, 15, 19]', '[1, 11, 12, 13, 14, 18, 19]', '[1, 11, 12, 13, 17, 18, 19]', '[1, 11, 12, 16, 17, 18, 19]'] assert len(out) == len(correct) and set(out) == set(correct)