Skip to content

Commit e963d59

Browse files
committed
Remove two random samples for hypothesis.
hypothesis by default randomly sample 200 experiments, as 2 of our variables have the option of 2 values this is wasted. I've removed them from the `given` calls and just included the 4 cases in a loop.
1 parent 4098a5d commit e963d59

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

tests/test_player.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from axelrod.action import Action
55
from ctypes import c_int, c_float, POINTER
66

7+
import itertools
8+
79
from hypothesis import given
810
from hypothesis.strategies import integers
911

@@ -31,17 +33,15 @@ def test_matches():
3133

3234

3335
@given(
34-
their_last_move=integers(min_value=0, max_value=1),
3536
move_number=integers(min_value=1, max_value=200),
3637
my_score=integers(min_value=0, max_value=200),
3738
their_score=integers(min_value=0, max_value=200),
38-
my_last_move=integers(min_value=0, max_value=1))
39-
def test_original_strategy(
40-
their_last_move, move_number, my_score, their_score, my_last_move
41-
):
42-
for strategy in all_strategies:
43-
player = Player(strategy)
44-
action = player.original_strategy(
45-
their_last_move, move_number, my_score, their_score, 0,
46-
my_last_move)
47-
assert action in (0, 1), print(f'{strategy} returned {action}')
39+
)
40+
def test_original_strategy(move_number, my_score, their_score):
41+
for their_last_move, my_last_move in itertools.product((0, 1), repeat=2):
42+
for strategy in all_strategies:
43+
player = Player(strategy)
44+
action = player.original_strategy(
45+
their_last_move, move_number, my_score, their_score, 0,
46+
my_last_move)
47+
assert action in (0, 1), print(f'{strategy} returned {action}')

0 commit comments

Comments
 (0)