Skip to content

Commit 1867f76

Browse files
committed
Add methods to allow context manager for Player
1 parent b34035e commit 1867f76

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/axelrod_fortran/player.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ def __init__(self, original_name):
2323
self.original_name = original_name
2424
self.original_function = self.original_name
2525

26+
def __enter__(self):
27+
return self
28+
29+
def __exit__(self, exc_type, exc_val, exc_tb):
30+
self.__original_function = None
31+
2632
@property
2733
def original_name(self):
2834
return self.__original_name

tests/test_player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_matches():
2626
for strategy in all_strategies:
2727
for opponent in (Alternator, Cooperator, Defector):
2828
players = (Player(strategy), opponent())
29-
match = Match(players, 50)
29+
match = Match(players, 200)
3030
assert all(
3131
action in (C, D) for interaction in match.play()
3232
for action in interaction)

0 commit comments

Comments
 (0)