def test_find_maze_not_found(bomb): """Test (not) finding a maze with invalid greens.""" maze = Maze(bomb) maze.set_greens([(10, 10), (0, 0)]) # greens won't match any maze expected_exception = 'No maze found for greens {}'.format(maze.greens) with pytest.raises(Exception, message=expected_exception): maze.find_maze()
def test_find_path(bomb, test_mazes): """Test finding paths through each maze.""" maze = Maze(bomb) for test_maze in test_mazes: maze.set_start(test_maze['start']) maze.set_goal(test_maze['goal']) maze.set_greens(test_maze['greens']) actual = maze.find_path() expected = test_maze['path'] assert actual == expected
def test_find_maze(bomb, test_mazes): """Test finding mazes.""" maze = Maze(bomb) maze.load_mazes() for test_maze in test_mazes: maze.set_greens(test_maze['greens']) actual = maze.find_maze() expected = test_maze['data'] assert actual == expected
def test_set_greens(bomb): """Test setting (overwriting) greens on a maze.""" maze = Maze(bomb) original_greens = [(0, 1), (2, 3)] maze.set_greens(original_greens) actual = maze.greens expected = original_greens assert actual == expected new_greens = [(4, 5), (6, 7)] maze.set_greens(new_greens) actual = maze.greens expected = new_greens assert actual == expected