示例#1
0
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()
示例#2
0
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"
示例#3
0
 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)
示例#4
0
def test_non_existent_constructor_parameter():
    with pytest.raises(AssertionError):
        Cell(c_type='x')
示例#5
0
def test_available_types():
    cell = Cell()
    types = cell.get_allowed_types()
    for type in types:
        cell = Cell(c_type=type)
        assert cell._type() == type
示例#6
0
def test_with_correct_type2():
    cell = Cell(c_type='_')
    assert cell._type() == '_'
示例#7
0
def test_no_constructor_given2():
    cell = Cell(c_type=None)
    assert cell._type() == 'X'
示例#8
0
def test_no_constructor_given():
    cell = Cell()
    assert cell._type() == 'X'