66 prob_end_tournaments , games )
77
88from hypothesis import given , settings
9- from hypothesis .strategies import random_module
109
1110stochastic_strategies = [s for s in axelrod .strategies if
1211 s ().classifier ['stochastic' ]]
@@ -20,31 +19,28 @@ def test_call(self):
2019 for p in strategies :
2120 self .assertIsInstance (p (), axelrod .Player )
2221
23- @given (strategies = strategy_lists (min_size = 1 , max_size = 50 ),
24- rm = random_module ())
22+ @given (strategies = strategy_lists (min_size = 1 , max_size = 50 ))
2523 @settings (max_examples = 10 , timeout = 0 )
26- def test_decorator (self , strategies , rm ):
24+ def test_decorator (self , strategies ):
2725 self .assertIsInstance (strategies , list )
2826 self .assertGreaterEqual (len (strategies ), 1 )
2927 self .assertLessEqual (len (strategies ), 50 )
3028 for strategy in strategies :
3129 self .assertIsInstance (strategy (), axelrod .Player )
3230
33- @given (strategies = strategy_lists (strategies = axelrod .basic_strategies ),
34- rm = random_module ())
31+ @given (strategies = strategy_lists (strategies = axelrod .basic_strategies ))
3532 @settings (max_examples = 10 , timeout = 0 )
36- def test_decorator_with_given_strategies (self , strategies , rm ):
33+ def test_decorator_with_given_strategies (self , strategies ):
3734 self .assertIsInstance (strategies , list )
3835 basic_player_names = [str (s ()) for s in axelrod .basic_strategies ]
3936 for strategy in strategies :
4037 player = strategy ()
4138 self .assertIsInstance (player , axelrod .Player )
4239 self .assertIn (str (player ), basic_player_names )
4340
44- @given (strategies = strategy_lists (strategies = stochastic_strategies ),
45- rm = random_module ())
41+ @given (strategies = strategy_lists (strategies = stochastic_strategies ))
4642 @settings (max_examples = 10 , timeout = 0 )
47- def test_decorator_with_stochastic_strategies (self , strategies , rm ):
43+ def test_decorator_with_stochastic_strategies (self , strategies ):
4844 self .assertIsInstance (strategies , list )
4945 stochastic_player_names = [str (s ()) for s in stochastic_strategies ]
5046 for strategy in strategies :
@@ -59,29 +55,24 @@ class TestMatch(unittest.TestCase):
5955 """
6056
6157 def test_call (self ):
62- match , seed = matches ().example ()
63- self .assertTrue (str (seed ).startswith ('random.seed' ))
58+ match = matches ().example ()
6459 self .assertIsInstance (match , axelrod .Match )
6560
66- @given (match_and_seed = matches (min_turns = 10 , max_turns = 50 ,
67- min_noise = 0 , max_noise = 1 ))
61+ @given (match = matches (min_turns = 10 , max_turns = 50 ,
62+ min_noise = 0 , max_noise = 1 ))
6863 @settings (max_examples = 10 , timeout = 0 )
69- def test_decorator (self , match_and_seed ):
70- match , seed = match_and_seed
71- self .assertTrue (str (seed ).startswith ('random.seed' ))
64+ def test_decorator (self , match ):
7265
7366 self .assertIsInstance (match , axelrod .Match )
7467 self .assertGreaterEqual (len (match ), 10 )
7568 self .assertLessEqual (len (match ), 50 )
7669 self .assertGreaterEqual (match .noise , 0 )
7770 self .assertLessEqual (match .noise , 1 )
7871
79- @given (match_and_seed = matches (min_turns = 10 , max_turns = 50 ,
80- min_noise = 0 , max_noise = 0 ))
72+ @given (match = matches (min_turns = 10 , max_turns = 50 ,
73+ min_noise = 0 , max_noise = 0 ))
8174 @settings (max_examples = 10 , timeout = 0 )
82- def test_decorator_with_no_noise (self , match_and_seed ):
83- match , seed = match_and_seed
84- self .assertTrue (str (seed ).startswith ('random.seed' ))
75+ def test_decorator_with_no_noise (self , match ):
8576
8677 self .assertIsInstance (match , axelrod .Match )
8778 self .assertGreaterEqual (len (match ), 10 )
@@ -92,19 +83,15 @@ def test_decorator_with_no_noise(self, match_and_seed):
9283class TestTournament (unittest .TestCase ):
9384
9485 def test_call (self ):
95- tournament , seed = tournaments ().example ()
96- self .assertTrue (str (seed ).startswith ('random.seed' ))
86+ tournament = tournaments ().example ()
9787 self .assertIsInstance (tournament , axelrod .Tournament )
9888
99- @given (tournament_and_seed = tournaments (min_turns = 2 , max_turns = 50 , min_noise = 0 ,
100- max_noise = 1 , min_repetitions = 2 ,
101- max_repetitions = 50 ,
102- max_size = 3 ))
89+ @given (tournament = tournaments (min_turns = 2 , max_turns = 50 , min_noise = 0 ,
90+ max_noise = 1 , min_repetitions = 2 ,
91+ max_repetitions = 50 ,
92+ max_size = 3 ))
10393 @settings (max_examples = 10 , timeout = 0 )
104- def test_decorator (self , tournament_and_seed ):
105- tournament , seed = tournament_and_seed
106- self .assertTrue (str (seed ).startswith ('random.seed' ))
107-
94+ def test_decorator (self , tournament ):
10895 self .assertIsInstance (tournament , axelrod .Tournament )
10996 self .assertLessEqual (tournament .turns , 50 )
11097 self .assertGreaterEqual (tournament .turns , 2 )
@@ -113,25 +100,19 @@ def test_decorator(self, tournament_and_seed):
113100 self .assertLessEqual (tournament .repetitions , 50 )
114101 self .assertGreaterEqual (tournament .repetitions , 2 )
115102
116- @given (tournament_and_seed = tournaments (strategies = axelrod .basic_strategies ,
117- max_size = 3 ))
103+ @given (tournament = tournaments (strategies = axelrod .basic_strategies ,
104+ max_size = 3 ))
118105 @settings (max_examples = 10 , timeout = 0 )
119- def test_decorator_with_given_strategies (self , tournament_and_seed ):
120- tournament , seed = tournament_and_seed
121- self .assertTrue (str (seed ).startswith ('random.seed' ))
122-
106+ def test_decorator_with_given_strategies (self , tournament ):
123107 self .assertIsInstance (tournament , axelrod .Tournament )
124108 basic_player_names = [str (s ()) for s in axelrod .basic_strategies ]
125109 for p in tournament .players :
126110 self .assertIn (str (p ), basic_player_names )
127111
128- @given (tournament_and_seed = tournaments (strategies = stochastic_strategies ,
129- max_size = 3 ))
112+ @given (tournament = tournaments (strategies = stochastic_strategies ,
113+ max_size = 3 ))
130114 @settings (max_examples = 10 , timeout = 0 )
131- def test_decorator_with_stochastic_strategies (self , tournament_and_seed ):
132- tournament , seed = tournament_and_seed
133- self .assertTrue (str (seed ).startswith ('random.seed' ))
134-
115+ def test_decorator_with_stochastic_strategies (self , tournament ):
135116 self .assertIsInstance (tournament , axelrod .Tournament )
136117 stochastic_player_names = [str (s ()) for s in stochastic_strategies ]
137118 for p in tournament .players :
@@ -141,21 +122,17 @@ def test_decorator_with_stochastic_strategies(self, tournament_and_seed):
141122class TestProbEndTournament (unittest .TestCase ):
142123
143124 def test_call (self ):
144- tournament , seed = prob_end_tournaments ().example ()
145- self .assertTrue (str (seed ).startswith ('random.seed' ))
125+ tournament = tournaments ().example ()
146126 self .assertIsInstance (tournament , axelrod .Tournament )
147127
148- @given (tournament_and_seed = prob_end_tournaments (min_prob_end = 0 ,
149- max_prob_end = 1 ,
150- min_noise = 0 , max_noise = 1 ,
151- min_repetitions = 2 ,
152- max_repetitions = 50 ,
153- max_size = 3 ))
128+ @given (tournament = prob_end_tournaments (min_prob_end = 0 ,
129+ max_prob_end = 1 ,
130+ min_noise = 0 , max_noise = 1 ,
131+ min_repetitions = 2 ,
132+ max_repetitions = 50 ,
133+ max_size = 3 ))
154134 @settings (max_examples = 10 , timeout = 0 )
155- def test_decorator (self , tournament_and_seed ):
156- tournament , seed = tournament_and_seed
157- self .assertTrue (str (seed ).startswith ('random.seed' ))
158-
135+ def test_decorator (self , tournament ):
159136 self .assertIsInstance (tournament , axelrod .ProbEndTournament )
160137 self .assertLessEqual (tournament .prob_end , 1 )
161138 self .assertGreaterEqual (tournament .prob_end , 0 )
@@ -164,25 +141,19 @@ def test_decorator(self, tournament_and_seed):
164141 self .assertLessEqual (tournament .repetitions , 50 )
165142 self .assertGreaterEqual (tournament .repetitions , 2 )
166143
167- @given (tournament_and_seed = prob_end_tournaments (
168- strategies = axelrod . basic_strategies , max_size = 3 ))
144+ @given (tournament = prob_end_tournaments (strategies = axelrod . basic_strategies ,
145+ max_size = 3 ))
169146 @settings (max_examples = 10 , timeout = 0 )
170- def test_decorator_with_given_strategies (self , tournament_and_seed ):
171- tournament , seed = tournament_and_seed
172- self .assertTrue (str (seed ).startswith ('random.seed' ))
173-
147+ def test_decorator_with_given_strategies (self , tournament ):
174148 self .assertIsInstance (tournament , axelrod .ProbEndTournament )
175149 basic_player_names = [str (s ()) for s in axelrod .basic_strategies ]
176150 for p in tournament .players :
177151 self .assertIn (str (p ), basic_player_names )
178152
179- @given (tournament_and_seed = prob_end_tournaments (
180- strategies = stochastic_strategies , max_size = 3 ))
153+ @given (tournament = prob_end_tournaments (strategies = stochastic_strategies ,
154+ max_size = 3 ))
181155 @settings (max_examples = 10 , timeout = 0 )
182- def test_decorator_with_stochastic_strategies (self , tournament_and_seed ):
183- tournament , seed = tournament_and_seed
184- self .assertTrue (str (seed ).startswith ('random.seed' ))
185-
156+ def test_decorator_with_stochastic_strategies (self , tournament ):
186157 self .assertIsInstance (tournament , axelrod .ProbEndTournament )
187158 stochastic_player_names = [str (s ()) for s in stochastic_strategies ]
188159 for p in tournament .players :
0 commit comments