Skip to content

Commit b11c3e6

Browse files
committed
Add test for correct match chunk generation.
Have implemented this in the hypothesis tests. There is still an example that checks the particular case of no noise.
1 parent 4aa2ab1 commit b11c3e6

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

axelrod/tests/unit/test_match_generator.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,27 @@ def setUpClass(cls):
217217
cls.players = [s() for s in test_strategies]
218218

219219
@given(repetitions=integers(min_value=1, max_value=test_repetitions),
220-
turns=integers(min_value=1, max_value=test_turns))
221-
@example(repetitions=test_repetitions, turns=test_turns)
222-
def test_build_match_chunks(self, repetitions, turns):
220+
turns=integers(min_value=1, max_value=test_turns),
221+
noise=floats(min_value=0, max_value=1))
222+
@example(repetitions=test_repetitions, turns=test_turns, noise=0)
223+
def test_build_match_chunks(self, repetitions, turns, noise):
223224
edges = [(0, 1), (1, 2), (3, 4)]
224225
sp = axelrod.SpatialMatches(
225-
self.players, turns, test_game, repetitions, edges)
226+
self.players, turns, test_game, repetitions, edges, noise)
226227
chunks = list(sp.build_match_chunks())
227-
match_definitions = [tuple(list(index_pair) + [repetitions])
228-
for (index_pair, match_params, repetitions) in chunks]
229-
expected_match_definitions = [(edge[0], edge[1], repetitions)
230-
for edge in edges]
231228

232-
self.assertEqual(sorted(match_definitions), sorted(expected_match_definitions))
229+
match_definitions = set()
230+
231+
cache = None
232+
expected_params = (turns, test_game, cache, noise)
233+
for index_pair, match_params, repetitions in chunks:
234+
match_definitions.add(tuple(list(index_pair) + [repetitions]))
235+
self.assertEqual(match_params, expected_params)
236+
237+
expected_match_definitions = set((edge[0], edge[1], repetitions)
238+
for edge in edges)
239+
240+
self.assertEqual(match_definitions, expected_match_definitions)
233241

234242
def test_len(self):
235243
edges = [(0, 1), (1, 2), (3, 4)]

0 commit comments

Comments
 (0)