1- import filecmp
21import unittest
32
4- from hypothesis import given , settings
3+ import filecmp
54
6- import axelrod
5+ import axelrod as axl
76from axelrod .strategy_transformers import FinalTransformer
87from axelrod .tests .property import tournaments
98
9+ from hypothesis import given , settings
1010
1111class TestTournament (unittest .TestCase ):
1212 @classmethod
1313 def setUpClass (cls ):
14- cls .game = axelrod .Game ()
14+ cls .game = axl .Game ()
1515 cls .players = [
16- axelrod .Cooperator (),
17- axelrod .TitForTat (),
18- axelrod .Defector (),
19- axelrod .Grudger (),
20- axelrod .GoByMajority (),
16+ axl .Cooperator (),
17+ axl .TitForTat (),
18+ axl .Defector (),
19+ axl .Grudger (),
20+ axl .GoByMajority (),
2121 ]
2222 cls .player_names = [str (p ) for p in cls .players ]
2323 cls .test_name = "test"
@@ -33,7 +33,7 @@ def setUpClass(cls):
3333 cls .expected_outcome .sort ()
3434
3535 @given (tournaments (
36- strategies = axelrod .short_run_time_strategies ,
36+ strategies = axl .short_run_time_strategies ,
3737 min_size = 10 ,
3838 max_size = 30 ,
3939 min_turns = 2 ,
@@ -51,7 +51,7 @@ def test_big_tournaments(self, tournament):
5151 )
5252
5353 def test_serial_play (self ):
54- tournament = axelrod .Tournament (
54+ tournament = axl .Tournament (
5555 name = self .test_name ,
5656 players = self .players ,
5757 game = self .game ,
@@ -63,7 +63,7 @@ def test_serial_play(self):
6363 self .assertEqual (actual_outcome , self .expected_outcome )
6464
6565 def test_parallel_play (self ):
66- tournament = axelrod .Tournament (
66+ tournament = axl .Tournament (
6767 name = self .test_name ,
6868 players = self .players ,
6969 game = self .game ,
@@ -78,12 +78,12 @@ def test_repeat_tournament_deterministic(self):
7878 """A test to check that tournament gives same results."""
7979 deterministic_players = [
8080 s ()
81- for s in axelrod .short_run_time_strategies
81+ for s in axl .short_run_time_strategies
8282 if not s ().classifier ["stochastic" ]
8383 ]
8484 files = []
8585 for _ in range (2 ):
86- tournament = axelrod .Tournament (
86+ tournament = axl .Tournament (
8787 name = "test" ,
8888 players = deterministic_players ,
8989 game = self .game ,
@@ -100,13 +100,13 @@ def test_repeat_tournament_stochastic(self):
100100 """
101101 files = []
102102 for _ in range (2 ):
103- axelrod .seed (0 )
103+ axl .seed (0 )
104104 stochastic_players = [
105105 s ()
106- for s in axelrod .short_run_time_strategies
106+ for s in axl .short_run_time_strategies
107107 if s ().classifier ["stochastic" ]
108108 ]
109- tournament = axelrod .Tournament (
109+ tournament = axl .Tournament (
110110 name = "test" ,
111111 players = stochastic_players ,
112112 game = self .game ,
@@ -121,14 +121,14 @@ def test_repeat_tournament_stochastic(self):
121121class TestNoisyTournament (unittest .TestCase ):
122122 def test_noisy_tournament (self ):
123123 # Defector should win for low noise
124- players = [axelrod .Cooperator (), axelrod .Defector ()]
125- tournament = axelrod .Tournament (players , turns = 5 , repetitions = 3 , noise = 0.0 )
124+ players = [axl .Cooperator (), axl .Defector ()]
125+ tournament = axl .Tournament (players , turns = 5 , repetitions = 3 , noise = 0.0 )
126126 results = tournament .play (progress_bar = False )
127127 self .assertEqual (results .ranked_names [0 ], "Defector" )
128128
129129 # If the noise is large enough, cooperator should win
130- players = [axelrod .Cooperator (), axelrod .Defector ()]
131- tournament = axelrod .Tournament (players , turns = 5 , repetitions = 3 , noise = 0.75 )
130+ players = [axl .Cooperator (), axl .Defector ()]
131+ tournament = axl .Tournament (players , turns = 5 , repetitions = 3 , noise = 0.75 )
132132 results = tournament .play (progress_bar = False )
133133 self .assertEqual (results .ranked_names [0 ], "Cooperator" )
134134
@@ -138,10 +138,10 @@ def test_players_do_not_know_match_length(self):
138138 """Create two players who should cooperate on last two turns if they
139139 don't know when those last two turns are.
140140 """
141- p1 = FinalTransformer (["D" , "D" ])(axelrod .Cooperator )()
142- p2 = FinalTransformer (["D" , "D" ])(axelrod .Cooperator )()
141+ p1 = FinalTransformer (["D" , "D" ])(axl .Cooperator )()
142+ p2 = FinalTransformer (["D" , "D" ])(axl .Cooperator )()
143143 players = [p1 , p2 ]
144- tournament = axelrod .Tournament (players , prob_end = 0.5 , repetitions = 1 )
144+ tournament = axl .Tournament (players , prob_end = 0.5 , repetitions = 1 )
145145 results = tournament .play (progress_bar = False )
146146 # Check that both plays always cooperated
147147 for rating in results .cooperating_rating :
@@ -152,12 +152,12 @@ def test_matches_have_different_length(self):
152152 A match between two players should have variable length across the
153153 repetitions
154154 """
155- p1 = axelrod .Cooperator ()
156- p2 = axelrod .Cooperator ()
157- p3 = axelrod .Cooperator ()
155+ p1 = axl .Cooperator ()
156+ p2 = axl .Cooperator ()
157+ p3 = axl .Cooperator ()
158158 players = [p1 , p2 , p3 ]
159- axelrod .seed (0 )
160- tournament = axelrod .Tournament (players , prob_end = 0.5 , repetitions = 2 )
159+ axl .seed (0 )
160+ tournament = axl .Tournament (players , prob_end = 0.5 , repetitions = 2 )
161161 results = tournament .play (progress_bar = False )
162162 # Check that match length are different across the repetitions
163163 self .assertNotEqual (results .match_lengths [0 ], results .match_lengths [1 ])
0 commit comments