def test_constructing_with_cellarray(): wall = Cell('X') ground = Cell('_') cell_array = np.array([[wall, wall, wall], [ground, ground, ground], [wall, wall, wall]]) maze = Maze(cell_array=cell_array) assert maze.grid.all() == cell_array.all()
def test_to_string(): wall = Cell('X') ground = Cell('_') cell_array = np.array([[wall, wall, wall], [ground, ground, ground], [wall, wall, wall]]) maze = Maze(cell_array=cell_array) maze_string = maze.to_string() assert maze_string == "X-X-X\n_-_-_\nX-X-X"
def __init__(self, cell_array=None, grid_shape=(10, 10)): if type(grid_shape) is not tuple: raise TypeError assert len(grid_shape) == 2 if cell_array is None: self.grid = np.full(grid_shape, Cell()) self.grid_shape = grid_shape else: self.grid = cell_array self.grid_shape = np.shape(cell_array)
def test_non_existent_constructor_parameter(): with pytest.raises(AssertionError): Cell(c_type='x')
def test_available_types(): cell = Cell() types = cell.get_allowed_types() for type in types: cell = Cell(c_type=type) assert cell._type() == type
def test_with_correct_type2(): cell = Cell(c_type='_') assert cell._type() == '_'
def test_no_constructor_given2(): cell = Cell(c_type=None) assert cell._type() == 'X'
def test_no_constructor_given(): cell = Cell() assert cell._type() == 'X'