@@ -3465,6 +3465,32 @@ def test_uci_info(self):
34653465 info = chess .engine ._parse_uci_info ("depth 1 seldepth 2 time 16 nodes 1 score cp 72 wdl 249 747 4 hashfull 0 nps 400 tbhits 0 multipv 1" , board )
34663466 self .assertEqual (info ["wdl" ], (249 , 747 , 4 ))
34673467
3468+ def test_uci_result (self ):
3469+ async def main ():
3470+ protocol = chess .engine .UciProtocol ()
3471+ mock = chess .engine .MockTransport (protocol )
3472+
3473+ mock .expect ("uci" , ["uciok" ])
3474+ await protocol .initialize ()
3475+ mock .assert_done ()
3476+
3477+ limit = chess .engine .Limit (time = 5 )
3478+ checkmate_board = chess .Board ("k7/7R/6R1/8/8/8/8/K7 w - - 0 1" )
3479+
3480+ mock .expect ("ucinewgame" )
3481+ mock .expect ("isready" , ["readyok" ])
3482+ mock .expect ("position fen k7/7R/6R1/8/8/8/8/K7 w - - 0 1" )
3483+ mock .expect ("go movetime 5000" , ["bestmove g6g8" ])
3484+ result = await protocol .play (checkmate_board , limit , game = "checkmate" )
3485+ self .assertEqual (result .move , checkmate_board .parse_uci ("g6g8" ))
3486+ checkmate_board .push (result .move )
3487+ self .assertTrue (checkmate_board .is_checkmate ())
3488+ await protocol .send_game_result (checkmate_board )
3489+ mock .assert_done ()
3490+
3491+ asyncio .set_event_loop_policy (chess .engine .EventLoopPolicy ())
3492+ asyncio .run (main ())
3493+
34683494 def test_hiarcs_bestmove (self ):
34693495 async def main ():
34703496 protocol = chess .engine .UciProtocol ()
0 commit comments