import importlib.util spec=importlib.util.spec_from_file_location('srv','/var/minis/workspace/drinking-games-ui/server.py') srv=importlib.util.module_from_spec(spec); spec.loader.exec_module(srv) def new_room(): room, host=srv.create_room('dice','房主','p-host') for _ in range(2): srv.add_bot(room['code'],'p-host') srv.start_room(room['code'],'p-host') return room room=new_room() srv.call_dice(room['code'],'p-host',5,2,'斋') print('first 5x2 zhai', room['currentCall']) assert room['currentCall']['mode']=='斋' room=new_room() srv.call_dice(room['code'],'p-host',5,2,'飞') print('first 5x2 fly', room['currentCall']) assert room['currentCall']['mode']=='飞' room=new_room() try: srv.call_dice(room['code'],'p-host',5,1,'飞') print('bad 5x1 fly accepted') except Exception as e: print('bad 5x1 fly rejected', str(e)) room=new_room() try: srv.call_dice(room['code'],'p-host',3,2,'斋') print('bad 3x2 accepted') except Exception as e: print('bad 3x2 rejected', str(e))