@@ -15,56 +15,56 @@ class TestAll(unittest.TestCase):
15
15
def test_init (self ):
16
16
for strategy in all_strategies :
17
17
player = Player (strategy )
18
- self . assertTrue ( player .classifier ["stochastic" ])
19
- self . assertEqual ( player .original_name , strategy )
20
- self . assertEqual ( player .original_function .argtypes , (
18
+ assert player .classifier ["stochastic" ]
19
+ assert player .original_name == strategy
20
+ assert player .original_function .argtypes == (
21
21
POINTER (c_int ), POINTER (c_int ), POINTER (c_int ), POINTER (c_int ),
22
- POINTER (c_float )))
23
- self . assertEqual ( player .original_function .restype , c_int )
22
+ POINTER (c_float ))
23
+ assert player .original_function .restype == c_int
24
24
25
25
def test_matches (self ):
26
26
for strategy in all_strategies :
27
27
for opponent in (Alternator , Cooperator , Defector ):
28
28
players = (Player (strategy ), opponent ())
29
29
match = Match (players , turns = 200 )
30
- self . assertTrue ( all (
30
+ assert all (
31
31
action in (C , D ) for interaction in match .play ()
32
- for action in interaction ))
32
+ for action in interaction )
33
33
34
34
def test_noisy_matches (self ):
35
35
for strategy in all_strategies :
36
36
for opponent in (Alternator , Cooperator , Defector ):
37
37
players = (Player (strategy ), opponent ())
38
38
match = Match (players , turns = 200 , noise = 0.5 )
39
- self . assertTrue ( all (
39
+ assert all (
40
40
action in (C , D ) for interaction in match .play ()
41
- for action in interaction ))
41
+ for action in interaction )
42
42
43
43
def test_probend_matches (self ):
44
44
for strategy in all_strategies :
45
45
for opponent in (Alternator , Cooperator , Defector ):
46
46
players = (Player (strategy ), opponent ())
47
47
match = Match (players , prob_end = 0.5 )
48
- self . assertTrue ( all (
48
+ assert all (
49
49
action in (C , D ) for interaction in match .play ()
50
- for action in interaction ))
50
+ for action in interaction )
51
51
52
52
def test_matches_with_different_game (self ):
53
53
for strategy in all_strategies :
54
54
for opponent in (Alternator , Cooperator , Defector ):
55
55
game = Game (r = 4 ,s = 0 ,p = 2 ,t = 6 )
56
56
players = (Player (strategy , game = game ), opponent ())
57
57
match = Match (players , turns = 200 , game = game )
58
- self . assertTrue ( all (
58
+ assert all (
59
59
action in (C , D ) for interaction in match .play ()
60
- for action in interaction ))
60
+ for action in interaction )
61
61
62
62
def test_random (self ):
63
63
random .seed (10 )
64
64
players = (Player ("KRANDOMC" ), Player ("KRANDOMC" ))
65
65
match = Match (players , 5 )
66
66
expected = [(C , D ), (C , D ), (C , C ), (C , D ), (C , D )]
67
- self . assertEqual ( match .play (), expected )
67
+ assert match .play () == expected
68
68
69
69
def test_original_strategy (self ):
70
70
"""
@@ -91,7 +91,7 @@ def test_original_strategy(self):
91
91
random_value = 0 ,
92
92
my_last_move = my_action )
93
93
94
- self . assertTrue ( my_action in [0 , 1 ])
94
+ assert my_action in [0 , 1 ]
95
95
96
96
scores = actions_to_scores [my_action , action ]
97
97
their_previous_action = action
0 commit comments