import pytest
from tests.helpers.test_helpers import *
from tests.helpers.output_place_ships import *
import battleship
from src import task6
def gogo_place_ships():
global ships_placed
board_ships_p = task6.make_boolean_square_board(7)
ships_placed = [[], []]
battleship.place_ships(0, 0, board_ships_p, ships_placed, False)
def gogo_attack():
global ships_placed
ships_placed = [[[(0,0),(1,0),(2,0),(3,0)],[(0,1),(1,1),(2,1)],[(0,2),(1,2),(2,2)],[(0,3),(1,3)],[(0,4),(1,4)]],[]]
battleship.attack(0, 1, board_opponent_ships_1, board_hits_1, ships_placed)
inps = [
(["1,1", "N", "1,2", "N", "1,3", "N", "1,4", "N", "1,5", "N"], 0, [[[(0,0),(1,0),(2,0),(3,0)],[(0,1),(1,1),(2,1)],[(0,2),(1,2),(2,2)],[(0,3),(1,3)],[(0,4),(1,4)]],[]]),
(["1,1", "Y", "2,1", "Y", "3,1", "Y", "4,1", "Y", "5,1", "Y"], 1, [[[(0,0),(0,1),(0,2),(0,3)],[(1,0),(1,1),(1,2)],[(2,0),(2,1),(2,2)],[(3,0),(3,1)],[(4,0),(4,1)]],[]]),
(["1,1", "Y", "2,1", "N", "5,7", "N", "7,5", "Y", "1,7", "N"], 2, [[[(0,0),(0,1),(0,2),(0,3)],[(1,0),(2,0),(3,0)],[(4,6),(5,6),(6,6)],[(6,4),(6,5)],[(0,6),(1,6)]],[]]),
]
@pytest.mark.parametrize('inputs, i, expected_ships_placed', inps)
def test_ships_placed(inputs, i, expected_ships_placed):
expected_output = expected_outputs[i].replace("\033c", "CLEAR")
result = intercept(gogo_place_ships, inputs).replace("\033c", "CLEAR")
assert result == expected_output#, f"Calling place_ships and providing the following inputs:\n{inputs}\nthe resulting outputs are:\n{result}\nwhen we expect:\n{expected_output}."
assert ships_placed == expected_ships_placed#, f"Calling place_ships and providing the following inputs:\n{inputs}\nthe resulting ships_placed are:\nships_placed = {ships_placed}\nwhen we expect:\nships_placed = {expected_ships_placed}."
-
Adam Blank authoredc1725e94