Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
cs1-25sp
project02
Commits
8bb21c97
Commit
8bb21c97
authored
2 months ago
by
Adam Blank
Browse files
Options
Download
Email Patches
Plain Diff
Update test_computer_placement.py
parent
f5df9856
Pipeline
#118937
canceled with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/0.D/test_computer_placement.py
+7
-7
tests/0.D/test_computer_placement.py
with
7 additions
and
7 deletions
+7
-7
tests/0.D/test_computer_placement.py
View file @
8bb21c97
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
))
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help