def test_a_cell_neighbours(): "Testing that a cell has eight neighbours" c = Cell(1, 1) neighbours = set(c.neighbours()) assert Cell(0, 0) in neighbours assert Cell(0, 1) in neighbours assert Cell(0, 2) in neighbours assert Cell(1, 0) in neighbours assert not Cell(1, 1) in neighbours assert Cell(1, 2) in neighbours assert Cell(2, 0) in neighbours assert Cell(2, 1) in neighbours assert Cell(2, 2) in neighbours
def test_a_cell_with_three_neighbours_spawns(x, y): cell = Cell(x, y) neighbours = list(cell.neighbours()) board = Board(neighbours[:3]) board = board.next_generation() assert cell in board.cells
def test_a_cell_can_be_placed_anywhere(x, y): c = Cell(x, y) neighbours = set(c.neighbours()) assert 8 == len(neighbours)