Skip to content

Commit

Permalink
Reduce the turns and repetitions for some tests.
Browse files Browse the repository at this point in the history
Possibly related to #1187
  • Loading branch information
drvinceknight committed Aug 14, 2018
1 parent 4fb14c8 commit 8f632c1
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions axelrod/tests/unit/test_tournament.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
axelrod.Defector,
axelrod.Grudger,
axelrod.GoByMajority]
test_repetitions = 5
test_turns = 100
test_repetitions = 3
test_turns = 10

test_prob_end = .5

Expand Down Expand Up @@ -90,8 +90,8 @@ def setUp(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=2,
repetitions=1
turns=self.test_turns,
repetitions=self.test_repetitions,
)

def test_init(self):
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_warning(self):
tournament = axelrod.Tournament(name=self.test_name,
players=self.players,
game=self.game,
turns=10,
turns=self.test_turns,
repetitions=1)
with warnings.catch_warnings(record=True) as w:
# Check that a warning is raised if no results set is built and no
Expand Down Expand Up @@ -164,10 +164,10 @@ def test_setup_output_no_filename(self):
def test_play_resets_num_interactions(self):
self.assertEqual(self.test_tournament.num_interactions, 0)
self.test_tournament.play(progress_bar=False)
self.assertEqual(self.test_tournament.num_interactions, 15)
self.assertEqual(self.test_tournament.num_interactions, 45)

self.test_tournament.play(progress_bar=False)
self.assertEqual(self.test_tournament.num_interactions, 15)
self.assertEqual(self.test_tournament.num_interactions, 45)

def test_play_changes_use_progress_bar(self):
self.assertTrue(self.test_tournament.use_progress_bar)
Expand Down Expand Up @@ -266,7 +266,7 @@ def test_serial_play(self):
turns=axelrod.DEFAULT_TURNS,
repetitions=self.test_repetitions)
results = tournament.play(progress_bar=False)
self.assertEqual(tournament.num_interactions, 75)
self.assertEqual(tournament.num_interactions, 45)

def test_serial_play_with_different_game(self):
# Test that a non default game is passed to the result set
Expand All @@ -287,7 +287,7 @@ def test_no_progress_bar_play(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)


Expand Down Expand Up @@ -319,7 +319,7 @@ def test_progress_bar_play(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)

RecordedTQDM.reset_record()
Expand Down Expand Up @@ -357,7 +357,7 @@ def test_progress_bar_play_parallel(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)

# progress_bar = False
Expand Down Expand Up @@ -419,11 +419,11 @@ def test_parallel_play(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)
results = tournament.play(processes=2, progress_bar=False)
self.assertIsInstance(results, axelrod.ResultSet)
self.assertEqual(tournament.num_interactions, 75)
self.assertEqual(tournament.num_interactions, 45)

# The following relates to #516
players = [axelrod.Cooperator(), axelrod.Defector(),
Expand All @@ -443,20 +443,20 @@ def test_parallel_play_with_writing_to_file(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)

results = tournament.play(processes=2, progress_bar=False,
filename=self.filename)
self.assertIsInstance(results, axelrod.ResultSet)
self.assertEqual(tournament.num_interactions, 75)
self.assertEqual(tournament.num_interactions, 45)

def test_run_serial(self):
tournament = axelrod.Tournament(
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)
tournament._write_interactions_to_file = MagicMock(
name='_write_interactions_to_file')
Expand All @@ -475,7 +475,7 @@ def __reduce__(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)
tournament._write_interactions_to_file = PickleableMock(
name='_write_interactions_to_file')
Expand All @@ -500,15 +500,15 @@ def test_n_workers(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)
self.assertEqual(tournament._n_workers(processes=1), max_processes)

tournament = axelrod.Tournament(
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)
self.assertEqual(tournament._n_workers(processes=max_processes+2),
max_processes)
Expand All @@ -524,7 +524,7 @@ def test_2_workers(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions,)
self.assertEqual(tournament._n_workers(processes=2), 2)

Expand All @@ -536,7 +536,7 @@ def test_start_workers(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)
chunks = tournament.match_generator.build_match_chunks()
for chunk in chunks:
Expand All @@ -555,7 +555,7 @@ def test_worker(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)

work_queue = Queue()
Expand All @@ -581,7 +581,7 @@ def test_build_result_set(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)
results = tournament.play(progress_bar=False)
self.assertIsInstance(results, axelrod.ResultSet)
Expand All @@ -591,7 +591,7 @@ def test_no_build_result_set(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=axelrod.DEFAULT_TURNS,
turns=self.test_turns,
repetitions=self.test_repetitions)

tournament._calculate_results = MagicMock(name='_calculate_results')
Expand Down Expand Up @@ -655,7 +655,7 @@ def test_match_cache_is_used(self):
FakeRandom.classifier["stochastic"] = False
p1 = FakeRandom()
p2 = FakeRandom()
tournament = axelrod.Tournament((p1, p2), turns=5, repetitions=2)
tournament = axelrod.Tournament((p1, p2), turns=self.test_turns, repetitions=2)
results = tournament.play(progress_bar=False)
for player_scores in results.scores:
self.assertEqual(player_scores[0], player_scores[1])
Expand All @@ -666,7 +666,7 @@ def test_write_interactions(self):
name=self.test_name,
players=self.players,
game=self.game,
turns=2,
turns=self.test_turns,
repetitions=2)
tournament._write_interactions_to_file = MagicMock(name='_write_interactions_to_file')
# Mocking this as it is called by play
Expand Down Expand Up @@ -782,7 +782,7 @@ def test_init(self):
self.assertEqual(tournament.match_generator.edges, tournament.edges)
self.assertEqual(len(tournament.players), len(test_strategies))
self.assertEqual(tournament.game.score((C, C)), (3, 3))
self.assertEqual(tournament.turns, 100)
self.assertEqual(tournament.turns, 10)
self.assertEqual(tournament.repetitions, 10)
self.assertEqual(tournament.name, 'test')
self.assertIsInstance(tournament._logger, logging.Logger)
Expand Down

0 comments on commit 8f632c1

Please sign in to comment.