Commit 8bb21c97 authored by Adam Blank's avatar Adam Blank
Browse files

Update test_computer_placement.py

parent f5df9856
Pipeline #118937 canceled with stage
Showing with 7 additions and 7 deletions
+7 -7
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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment