1919
2020
2121class TestStrategyList (unittest .TestCase ):
22- def test_call (self ):
23- strategies = strategy_lists ().example ()
22+ # MG: Replaced .example() with @given for generating strategies
23+ @given (strategies = strategy_lists ())
24+ @settings (max_examples = 3 )
25+ def test_call (self , strategies ):
2426 self .assertIsInstance (strategies , list )
2527 for p in strategies :
2628 self .assertIsInstance (p (), axl .Player )
2729
2830 @given (strategies = strategy_lists (min_size = 1 , max_size = 50 ))
29- @settings (max_examples = 5 )
31+ @settings (max_examples = 3 )
3032 def test_decorator (self , strategies ):
3133 self .assertIsInstance (strategies , list )
3234 self .assertGreaterEqual (len (strategies ), 1 )
@@ -35,7 +37,7 @@ def test_decorator(self, strategies):
3537 self .assertIsInstance (strategy (), axl .Player )
3638
3739 @given (strategies = strategy_lists (strategies = axl .basic_strategies ))
38- @settings (max_examples = 5 )
40+ @settings (max_examples = 3 )
3941 def test_decorator_with_given_strategies (self , strategies ):
4042 self .assertIsInstance (strategies , list )
4143 basic_player_names = [str (s ()) for s in axl .basic_strategies ]
@@ -50,12 +52,14 @@ class TestMatch(unittest.TestCase):
5052 Test that the composite method works
5153 """
5254
53- def test_call (self ):
54- match = matches ().example ()
55+ # MG: Replaced .example() with @given for match generation
56+ @given (match = matches ())
57+ @settings (max_examples = 3 )
58+ def test_call (self , match ):
5559 self .assertIsInstance (match , axl .Match )
5660
5761 @given (match = matches (min_turns = 10 , max_turns = 50 , min_noise = 0 , max_noise = 1 ))
58- @settings (max_examples = 5 )
62+ @settings (max_examples = 3 )
5963 def test_decorator (self , match ):
6064 self .assertIsInstance (match , axl .Match )
6165 self .assertGreaterEqual (len (match ), 10 )
@@ -64,7 +68,7 @@ def test_decorator(self, match):
6468 self .assertLessEqual (match .noise , 1 )
6569
6670 @given (match = matches (min_turns = 10 , max_turns = 50 , min_noise = 0 , max_noise = 0 ))
67- @settings (max_examples = 5 )
71+ @settings (max_examples = 3 )
6872 def test_decorator_with_no_noise (self , match ):
6973 self .assertIsInstance (match , axl .Match )
7074 self .assertGreaterEqual (len (match ), 10 )
@@ -73,8 +77,10 @@ def test_decorator_with_no_noise(self, match):
7377
7478
7579class TestTournament (unittest .TestCase ):
76- def test_call (self ):
77- tournament = tournaments ().example ()
80+ # MG: Replaced .example() with @given for tournament generation
81+ @given (tournament = tournaments ())
82+ @settings (max_examples = 3 )
83+ def test_call (self , tournament ):
7884 self .assertIsInstance (tournament , axl .Tournament )
7985
8086 @given (
@@ -88,7 +94,7 @@ def test_call(self):
8894 max_size = 3 ,
8995 )
9096 )
91- @settings (max_examples = 5 )
97+ @settings (max_examples = 3 )
9298 def test_decorator (self , tournament ):
9399 self .assertIsInstance (tournament , axl .Tournament )
94100 self .assertLessEqual (tournament .turns , 50 )
@@ -99,7 +105,7 @@ def test_decorator(self, tournament):
99105 self .assertGreaterEqual (tournament .repetitions , 2 )
100106
101107 @given (tournament = tournaments (strategies = axl .basic_strategies , max_size = 3 ))
102- @settings (max_examples = 5 )
108+ @settings (max_examples = 3 )
103109 def test_decorator_with_given_strategies (self , tournament ):
104110 self .assertIsInstance (tournament , axl .Tournament )
105111 basic_player_names = [str (s ()) for s in axl .basic_strategies ]
@@ -108,8 +114,9 @@ def test_decorator_with_given_strategies(self, tournament):
108114
109115
110116class TestProbEndTournament (unittest .TestCase ):
111- def test_call (self ):
112- tournament = tournaments ().example ()
117+ @given (tournament = prob_end_tournaments ())
118+ @settings (max_examples = 3 )
119+ def test_call (self , tournament ):
113120 self .assertIsInstance (tournament , axl .Tournament )
114121
115122 @given (
@@ -123,7 +130,7 @@ def test_call(self):
123130 max_size = 3 ,
124131 )
125132 )
126- @settings (max_examples = 5 )
133+ @settings (max_examples = 3 )
127134 def test_decorator (self , tournament ):
128135 self .assertIsInstance (tournament , axl .Tournament )
129136 self .assertLessEqual (tournament .prob_end , 1 )
@@ -138,7 +145,7 @@ def test_decorator(self, tournament):
138145 strategies = axl .basic_strategies , max_size = 3
139146 )
140147 )
141- @settings (max_examples = 5 )
148+ @settings (max_examples = 3 )
142149 def test_decorator_with_given_strategies (self , tournament ):
143150 self .assertIsInstance (tournament , axl .Tournament )
144151 basic_player_names = [str (s ()) for s in axl .basic_strategies ]
@@ -147,8 +154,9 @@ def test_decorator_with_given_strategies(self, tournament):
147154
148155
149156class TestSpatialTournament (unittest .TestCase ):
150- def test_call (self ):
151- tournament = spatial_tournaments ().example ()
157+ @given (tournament = spatial_tournaments ())
158+ @settings (max_examples = 3 )
159+ def test_call (self , tournament ):
152160 self .assertIsInstance (tournament , axl .Tournament )
153161
154162 @given (
@@ -162,7 +170,7 @@ def test_call(self):
162170 max_size = 3 ,
163171 )
164172 )
165- @settings (max_examples = 5 )
173+ @settings (max_examples = 3 )
166174 def test_decorator (self , tournament ):
167175 self .assertIsInstance (tournament , axl .Tournament )
168176 self .assertLessEqual (tournament .turns , 50 )
@@ -177,7 +185,7 @@ def test_decorator(self, tournament):
177185 strategies = axl .basic_strategies , max_size = 3
178186 )
179187 )
180- @settings (max_examples = 5 )
188+ @settings (max_examples = 3 )
181189 def test_decorator_with_given_strategies (self , tournament ):
182190 self .assertIsInstance (tournament , axl .Tournament )
183191 basic_player_names = [str (s ()) for s in axl .basic_strategies ]
@@ -186,8 +194,9 @@ def test_decorator_with_given_strategies(self, tournament):
186194
187195
188196class TestProbEndSpatialTournament (unittest .TestCase ):
189- def test_call (self ):
190- tournament = prob_end_spatial_tournaments ().example ()
197+ @given (tournament = prob_end_spatial_tournaments ())
198+ @settings (max_examples = 3 )
199+ def test_call (self , tournament ):
191200 self .assertIsInstance (tournament , axl .Tournament )
192201
193202 @given (
@@ -201,7 +210,7 @@ def test_call(self):
201210 max_size = 3 ,
202211 )
203212 )
204- @settings (max_examples = 5 )
213+ @settings (max_examples = 3 )
205214 def test_decorator (self , tournament ):
206215 self .assertIsInstance (tournament , axl .Tournament )
207216 self .assertLessEqual (tournament .prob_end , 1 )
@@ -216,7 +225,7 @@ def test_decorator(self, tournament):
216225 strategies = axl .basic_strategies , max_size = 3
217226 )
218227 )
219- @settings (max_examples = 5 )
228+ @settings (max_examples = 3 )
220229 def test_decorator_with_given_strategies (self , tournament ):
221230 self .assertIsInstance (tournament , axl .Tournament )
222231 basic_player_names = [str (s ()) for s in axl .basic_strategies ]
@@ -225,18 +234,19 @@ def test_decorator_with_given_strategies(self, tournament):
225234
226235
227236class TestGame (unittest .TestCase ):
228- def test_call (self ):
229- game = games ().example ()
237+ @given (game = games ())
238+ @settings (max_examples = 3 )
239+ def test_call (self , game ):
230240 self .assertIsInstance (game , axl .Game )
231241
232242 @given (game = games ())
233- @settings (max_examples = 5 )
243+ @settings (max_examples = 3 )
234244 def test_decorator (self , game ):
235245 self .assertIsInstance (game , axl .Game )
236246 r , p , s , t = game .RPST ()
237247 self .assertTrue ((2 * r ) > (t + s ) and (t > r > p > s ))
238248
239249 @given (game = games (prisoners_dilemma = False ))
240- @settings (max_examples = 5 )
250+ @settings (max_examples = 3 )
241251 def test_decorator_unconstrained (self , game ):
242252 self .assertIsInstance (game , axl .Game )
0 commit comments