File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -307,7 +307,10 @@ class GamePlayers:
307307 raise ValueError (f" Game has multiple players with label '{index}'" )
308308 return matches[0 ]
309309 if isinstance (index, int ):
310- return Player.wrap(self .game.deref().GetPlayer(index + 1 ))
310+ try :
311+ return Player.wrap(self .game.deref().GetPlayer(index + 1 ))
312+ except IndexError :
313+ raise IndexError (" Index out of range" ) from None
311314 raise TypeError (f" Player index must be int or str, not {index.__class__.__name__}" )
312315
313316 @property
Original file line number Diff line number Diff line change @@ -40,11 +40,12 @@ def test_player_index_by_string():
4040def test_player_index_out_of_range ():
4141 game = gbt .Game .new_table ([2 , 2 ])
4242 assert len (game .players ) == 2
43- with pytest .raises (IndexError ):
43+ exp_error_msg = "Index out of range"
44+ with pytest .raises (IndexError , match = exp_error_msg ):
4445 _ = game .players [2 ]
45- with pytest .raises (IndexError ):
46+ with pytest .raises (IndexError , match = exp_error_msg ):
4647 _ = game .players [3 ]
47- with pytest .raises (IndexError ):
48+ with pytest .raises (IndexError , match = exp_error_msg ):
4849 _ = game .players [- 1 ]
4950
5051
You can’t perform that action at this time.
0 commit comments