def test_init(): column = Column() assert column.size == 0 column = Column(None, None, None) assert column.size == 3 column = Column(None, None) assert column.size == 2 column = Column(None) assert column.size == 1 print column
def test_grid_assignment0(): SIZE = 3 grid = Grid([Column([(x,y) for y in range(SIZE)]) for x in range(SIZE)]) assert grid[0][0] == (0,0) assert grid[1][2] == (1,2) for x in range(SIZE): for y in range(SIZE): assert grid[x][y] == (x, y)
def test_grid_and_squares(): SIZE = 3 grid = Grid([Column([Square(x,y) for y in range(SIZE)]) for x in range(SIZE)]) assert isinstance(grid[0][0], Square) square = grid[0][0] print square assert (square.x, square.y) == (0,0) square0 = grid[1][2] print square0 assert (square0.x, square0.y) == (1,2)
def test_grids_assignment(): grid = Grid([Column(i, i, i) for i in range(3)]) assert isinstance(grid[0], Column) assert grid[0][0] == 0 print grid[0][1] assert grid[0][1] == 0 print grid [0][2] assert grid[0][2] == 0 print grid[2][1] assert grid[2][1] == 2
from board import Square, Grid, Column SIZE = 3 grid = Grid([Column([(i, j) for j in range(SIZE)]) for i in range(SIZE)]) print grid
def test_setitem(): column = Column(1, 2, 3) assert (column[0], column[1], column[2]) == (1, 2, 3) column[0] = 4 assert column[0] == 4
def test_getitem(): column = Column(1, None, None) assert column[0] == 1
def test_grids_init(): column0 = Column(None, None, None) grid = Grid([Column(None,None,None) for i in range(3)]) print type(grid[0]) assert isinstance(grid[0], Column)
def create_graphic_board(size=SIZE): return Grid([ Column([Tile(DISPLAY_SURF, x, y) for y in range(size)]) for x in range(size) ])