def test_set_ship(self): base = SeaField(5, 5) base.set_ship(1, 1, 3) ship = [(1, 1), (2, 1), (3, 1)] for cell in base._cells: if (cell.x, cell.y) in ship: assert cell.value == Cell.SHIP else: assert cell.value == Cell.EMPTY
def test_has_any_alive_ship(self): base = SeaField(5, 5) base.set_ship(1, 1, 2) assert base.has_any_alive_ship() is True base.set(0, 1, Cell.HIT) assert base.has_any_alive_ship() is True base.set(1, 1, Cell.HIT) assert base.has_any_alive_ship() is True base.set(2, 1, Cell.HIT) assert base.has_any_alive_ship() is False