Skip to content

Commit e3bfc46

Browse files
committed
Fix remaining tests
1 parent 1661ea0 commit e3bfc46

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

axelrod/makes_use_of.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,27 @@ def method_makes_use_of(method: Callable) -> Set[Text]:
1515
return result
1616

1717

18-
def makes_use_of(player: Type[Player]) -> Set[Text]:
19-
if not isinstance(player, Player):
20-
player = player()
21-
18+
def class_makes_use_of(cls) -> Set[Text]:
2219
result = set()
23-
for method in inspect.getmembers(player, inspect.ismethod):
20+
for method in inspect.getmembers(cls, inspect.ismethod):
2421
if method[0] == "__init__":
2522
continue
2623
result.update(method_makes_use_of(method[1]))
2724
return result
2825

2926

30-
# def makes_use_of_variant(
31-
# player_or_method: Union[Callable, Type[Player]], verbose=False
32-
# ) -> Set[Text]:
33-
# """A version of makes_use_of that works on functions or player classes."""
34-
# try:
35-
# return method_makes_use_of(player_or_method)
36-
# except:
37-
# return makes_use_of(player_or_method)
27+
def makes_use_of(player: Type[Player]) -> Set[Text]:
28+
if not isinstance(player, Player):
29+
player = player()
30+
31+
return class_makes_use_of(player)
32+
33+
34+
def makes_use_of_variant(
35+
player_or_method: Union[Callable, Type[Player]], verbose=False
36+
) -> Set[Text]:
37+
"""A version of makes_use_of that works on functions or player classes."""
38+
try:
39+
return method_makes_use_of(player_or_method)
40+
except:
41+
return class_makes_use_of(player_or_method)

axelrod/strategy_transformers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def strategy(self, opponent):
135135
classifier = original_classifier
136136
classifier_makes_use_of = makes_use_of(PlayerClass)
137137
classifier_makes_use_of.update(
138-
method_makes_use_of(strategy_wrapper))
138+
makes_use_of_variant(strategy_wrapper))
139139
classifier["makes_use_of"] = classifier_makes_use_of
140140

141141
# Define the new __repr__ method to add the wrapper arguments

axelrod/tests/strategies/test_human.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TestHumanClass(TestPlayer):
3737
expected_classifier = {
3838
"memory_depth": float("inf"),
3939
"stochastic": True,
40-
"makes_use_of": set(["length", "game"]),
40+
"makes_use_of": set(),
4141
"long_run_time": True,
4242
"inspects_source": True,
4343
"manipulates_source": False,

axelrod/tests/strategies/test_memoryone.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ class TestWinStayLoseShift(TestPlayer):
2424
"manipulates_state": False,
2525
}
2626

27-
def test_class_classification(self):
28-
self.assertEqual(self.player.classifier, self.expected_classifier)
29-
3027
def test_strategy(self):
3128
# Check that switches if does not get best payoff.
3229
actions = [(C, C), (C, D), (D, C), (D, D), (C, C)]

0 commit comments

Comments
 (0)