@@ -17,37 +17,20 @@ def test_outcome_add(game: gbt.Game):
1717)
1818def test_outcome_delete (game : gbt .Game ):
1919 outcome_count = len (game .outcomes )
20- game .delete_outcome (game .outcomes [ 0 ] )
20+ game .delete_outcome (next ( iter ( game .outcomes )) )
2121 assert len (game .outcomes ) == outcome_count - 1
2222
2323
24- @pytest .mark .parametrize (
25- "game,label" ,
26- [(gbt .Game .new_table ([2 , 2 ]), "outcome label" )]
27- )
28- def test_outcome_label (game : gbt .Game , label : str ):
29- game .outcomes [0 ].label = label
30- assert game .outcomes [0 ].label == label
31-
32-
3324@pytest .mark .parametrize (
3425 "game,label" ,
3526 [(gbt .Game .new_table ([2 , 2 ]), "outcome label" )]
3627)
3728def test_outcome_index_label (game : gbt .Game , label : str ):
38- game . outcomes [ 0 ]. label = label
39- assert game . outcomes [ 0 ] == game . outcomes [ label ]
29+ outcome = next ( iter ( game . outcomes ))
30+ outcome . label = label
4031 assert game .outcomes [label ].label == label
4132
4233
43- @pytest .mark .parametrize (
44- "game" , [gbt .Game .new_table ([2 , 2 ])]
45- )
46- def test_outcome_index_int_range (game : gbt .Game ):
47- with pytest .raises (IndexError ):
48- _ = game .outcomes [2 * len (game .outcomes )]
49-
50-
5134@pytest .mark .parametrize (
5235 "game" , [gbt .Game .new_table ([2 , 2 ])]
5336)
@@ -68,27 +51,28 @@ def test_outcome_payoff_by_player_label():
6851 game = gbt .Game .new_table ([2 , 2 ])
6952 game .players [0 ].label = "joe"
7053 game .players [1 ].label = "dan"
71- game .outcomes [0 ]["joe" ] = 1
72- game .outcomes [0 ]["dan" ] = 2
73- game .outcomes [1 ]["joe" ] = 3
74- game .outcomes [1 ]["dan" ] = 4
75- assert game .outcomes [0 ]["joe" ] == 1
76- assert game .outcomes [0 ]["dan" ] == 2
77- assert game .outcomes [1 ]["joe" ] == 3
78- assert game .outcomes [1 ]["dan" ] == 4
54+ outcomes = list (game .outcomes )
55+ outcomes [0 ]["joe" ] = 1
56+ outcomes [0 ]["dan" ] = 2
57+ outcomes [1 ]["joe" ] = 3
58+ outcomes [1 ]["dan" ] = 4
59+ assert outcomes [0 ]["joe" ] == 1
60+ assert outcomes [0 ]["dan" ] == 2
61+ assert outcomes [1 ]["joe" ] == 3
62+ assert outcomes [1 ]["dan" ] == 4
7963
8064
8165def test_outcome_payoff_by_player ():
8266 game = gbt .Game .new_table ([2 , 2 ])
8367 game .players [0 ].label = "joe"
8468 game .players [1 ].label = "dan"
85- game . outcomes [ 0 ][ "joe" ] = 1
86- game . outcomes [0 ]["dan " ] = 2
87- game . outcomes [1 ]["joe " ] = 3
88- game . outcomes [1 ]["dan " ] = 4
89- player1 = game . players [ 0 ]
90- player2 = game .players [ 1 ]
91- assert game . outcomes [0 ][player1 ] == 1
92- assert game . outcomes [0 ][player2 ] == 2
93- assert game . outcomes [1 ][player1 ] == 3
94- assert game . outcomes [1 ][player2 ] == 4
69+ outcomes = list ( game . outcomes )
70+ outcomes [0 ]["joe " ] = 1
71+ outcomes [0 ]["dan " ] = 2
72+ outcomes [1 ]["joe " ] = 3
73+ outcomes [ 1 ][ "dan" ] = 4
74+ player1 , player2 = game .players
75+ assert outcomes [0 ][player1 ] == 1
76+ assert outcomes [0 ][player2 ] == 2
77+ assert outcomes [1 ][player1 ] == 3
78+ assert outcomes [1 ][player2 ] == 4
0 commit comments