Skip to content

Commit 4de9c7a

Browse files
authored
Merge pull request #716 from marcharper/634
Fix prober tests in conjunction with test_reponses and attrs
2 parents 5c3c981 + b2941f1 commit 4de9c7a

File tree

5 files changed

+23
-32
lines changed

5 files changed

+23
-32
lines changed

axelrod/strategies/prober.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ class RemorsefulProber(NaiveProber):
206206

207207
name = 'Remorseful Prober'
208208
classifier = {
209-
'memory_depth': 2, # It remembers if it's previous move was random
209+
'memory_depth': 2, # It remembers if its previous move was random
210210
'stochastic': True,
211211
'makes_use_of': set(),
212212
'long_run_time': False,

axelrod/tests/unit/test_apavlov.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def test_strategy(self):
9090
opponent.history.append(C)
9191
self.assertEqual(player.strategy(opponent), C)
9292

93-
9493
self.responses_test([C, C, C, C, C, D], [C, C, C, C, D, D], [D],
9594
attrs={"opponent_class": "Random"})
9695
self.responses_test([C, D, D, C, C, C], [D, D, C, C, C, C], [D],

axelrod/tests/unit/test_averagecopier.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,14 @@ def test_strategy(self):
2727
self.responses_test([], [], [D], random_seed=2)
2828

2929
def test_when_oppenent_all_Cs(self):
30-
"""
31-
Tests that if opponent has played all C then player chooses C
32-
"""
30+
"""Tests that if opponent has played all C then player chooses C."""
3331
self.responses_test([C, C, C, C], [C, C, C, C], [C, C, C],
3432
random_seed=5)
3533

3634
def test_when_opponent_all_Ds(self):
37-
"""
38-
Tests that if opponent has played all D then player chooses D
39-
"""
40-
self.responses_test([C, C, C, C], [D, D, D, D], [D, D, D], random_seed=5)
35+
"""Tests that if opponent has played all D then player chooses D."""
36+
self.responses_test([C, C, C, C], [D, D, D, D], [D, D, D],
37+
random_seed=5)
4138

4239

4340
class TestNiceAverageCopier(TestPlayer):

axelrod/tests/unit/test_axelrod_first.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class TestFeld(TestPlayer):
9999
'manipulates_state': False
100100
}
101101

102-
103102
def test_strategy(self):
104103
self.first_play_test(C)
105104
# Test retaliate

axelrod/tests/unit/test_prober.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class TestRemorsefulProber(TestPlayer):
183183
}
184184

185185
def test_strategy(self):
186-
"Randomly defects (probes) and always retaliates like tit for tat."
186+
"""Randomly defects (probes) and always retaliates like tit for tat."""
187187
self.first_play_test(C)
188188

189189
player = self.player(0.4)
@@ -192,32 +192,22 @@ def test_strategy(self):
192192
opponent.history = [C, D]
193193
self.assertEqual(player.strategy(opponent), D)
194194

195-
def test_random_defection(self):
196-
# Random defection
197-
player = self.player(0.4)
198-
opponent = axelrod.Random()
199-
test_responses(self, player, opponent, [C], [C], [D], random_seed=1)
200-
201195
def test_remorse(self):
202-
"""After probing, if opponent retaliates, will offer a C"""
196+
"""After probing, if opponent retaliates, will offer a C."""
203197
player = self.player(0.4)
204-
opponent = axelrod.Random()
198+
opponent = axelrod.Cooperator()
205199

206-
random.seed(0)
207-
player.history = [C]
208-
opponent.history = [C]
209-
self.assertEqual(player.strategy(opponent), D) # Random defection
210-
self.assertEqual(player.probing, True)
200+
test_responses(self, player, opponent, [C], [C], [C],
201+
random_seed=0, attrs={'probing': False})
211202

212-
player.history = [C, D]
213-
opponent.history = [C, D]
214-
self.assertEqual(player.strategy(opponent), C) # Remorse
215-
self.assertEqual(player.probing, False)
203+
test_responses(self, player, opponent, [C], [C], [D],
204+
random_seed=1, attrs={'probing': True})
216205

217-
player.history = [C, D, C]
218-
opponent.history = [C, D, D]
219-
self.assertEqual(player.strategy(opponent), D)
220-
self.assertEqual(player.probing, False)
206+
test_responses(self, player, opponent, [C, D], [C, D], [D],
207+
attrs={'probing': False})
208+
209+
test_responses(self, player, opponent, [C, D, C], [C, D, D], [D],
210+
attrs={'probing': False})
221211

222212
def test_reduction_to_TFT(self):
223213
player = self.player(0)
@@ -236,3 +226,9 @@ def test_reset_probing(self):
236226
player.probing = True
237227
player.reset()
238228
self.assertFalse(player.probing)
229+
230+
def test_random_defection(self):
231+
# Random defection
232+
player = self.player(0.4)
233+
opponent = axelrod.Random()
234+
test_responses(self, player, opponent, [C], [C], [D], random_seed=1)

0 commit comments

Comments
 (0)