diff --git a/tests/0.D/test_computer_placement.py b/tests/0.D/test_computer_placement.py index f8a2250a2e96df0fb9d8020ec5948c16ea04f935..bab9098ac7dbed46691c7cc099e7d6e211e5e4ca 100644 --- a/tests/0.D/test_computer_placement.py +++ b/tests/0.D/test_computer_placement.py @@ -1,6 +1,6 @@ import random import pytest -from src.computer_placement import choose_orientation_and_location, generate_ship_coordinates, place_ship, is_conflict, place_ships +from src.computer_placement import choose_orientation_and_location, generate_ship_coordinates, is_conflict, place_ships from tests.helpers.conflicts_test_data import conflicts from tests.helpers.naming import apply_names @@ -35,7 +35,8 @@ def test_choose_orientation_and_location(size, seed): trues = ors.count(True) falses = ors.count(False) - assert 1500 > abs(trues - falses), 'the orientations should be approximately uniformly random' + assert 1500 > abs( + trues - falses), 'the orientations should be approximately uniformly random' for orientation, location in zip(ors, locs): if size <= 0: @@ -44,11 +45,10 @@ def test_choose_orientation_and_location(size, seed): assert None is location, 'there is no location to place the ship at for size > ' + \ str(BOARD_SIZE) + '; so, you should return None' else: - try: - x, y = location - except TypeError: - raise AssertionError( - 'the return value of choose_orientation_and_location should always be a tuple') + assert location is not None and len( + location) == 2, 'the return value of choose_orientation_and_location should always be a tuple of size 2' + + x, y = location assert 0 <= x <= 7 and 0 <= y <= 7, 'all coordinates must be between 0 and 7; you returned ' + \ str((x, y))