Skip to content

Commit b34035e

Browse files
committed
Add with statement to control lifetime of player object
1 parent a5bdd53 commit b34035e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/test_player.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ def test_matches():
3636
move_number=integers(min_value=1, max_value=200),
3737
my_score=integers(min_value=0, max_value=200),
3838
their_score=integers(min_value=0, max_value=200),
39-
)
39+
)
4040
def test_original_strategy(move_number, my_score, their_score):
4141
for their_last_move, my_last_move in itertools.product((0, 1), repeat=2):
4242
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}')
43+
with Player(strategy) as player:
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)