예제 #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'