本文整理匯總了Python中gomill.gtp_controller.Gtp_controller.safe_do_command方法的典型用法代碼示例。如果您正苦於以下問題:Python Gtp_controller.safe_do_command方法的具體用法?Python Gtp_controller.safe_do_command怎麽用?Python Gtp_controller.safe_do_command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gomill.gtp_controller.Gtp_controller
的用法示例。
在下文中一共展示了Gtp_controller.safe_do_command方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_safe_do_command_closed_channel
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_do_command [as 別名]
def test_safe_do_command_closed_channel(tc):
# check it's ok to call safe_do_command() on a closed channel
channel = gtp_engine_fixtures.get_test_channel()
controller = Gtp_controller(channel, 'player test')
controller.safe_close()
tc.assertIsNone(controller.safe_do_command("test"))
tc.assertListEqual(channel.engine.commands_handled,
[('quit', [])])
tc.assertListEqual(controller.retrieve_error_messages(), [])
示例2: test_gtp_aliases_safe
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_do_command [as 別名]
def test_gtp_aliases_safe(tc):
channel = gtp_engine_fixtures.get_test_channel()
controller = Gtp_controller(channel, 'alias test')
controller.set_gtp_aliases({
'aliased' : 'test',
'aliased2' : 'nonesuch',
})
tc.assertIs(controller.safe_known_command("test"), True)
tc.assertIs(controller.safe_known_command("aliased"), True)
tc.assertIs(controller.safe_known_command("nonesuch"), False)
tc.assertIs(controller.safe_known_command("test"), True)
tc.assertIs(controller.safe_known_command("aliased"), True)
tc.assertIs(controller.safe_known_command("nonesuch"), False)
tc.assertEqual(controller.safe_do_command("test"), "test response")
tc.assertEqual(controller.safe_do_command("aliased"), "test response")
with tc.assertRaises(BadGtpResponse) as ar:
controller.safe_do_command("aliased2")
tc.assertEqual(ar.exception.gtp_error_message, "unknown command")
tc.assertEqual(ar.exception.gtp_command, "nonesuch")
示例3: test_safe_do_command
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_do_command [as 別名]
def test_safe_do_command(tc):
channel = gtp_engine_fixtures.get_test_channel()
controller = Gtp_controller(channel, 'player test')
tc.assertEqual(controller.safe_do_command("test", "ab"), "args: ab")
with tc.assertRaises(BadGtpResponse) as ar:
controller.safe_do_command("error")
tc.assertFalse(controller.channel_is_bad)
channel.fail_next_response = True
tc.assertIsNone(controller.safe_do_command("test"))
tc.assertTrue(controller.channel_is_bad)
tc.assertIsNone(controller.safe_do_command("test"))
tc.assertListEqual(
controller.retrieve_error_messages(),
["transport error reading response to 'test' from player test:\n"
"forced failure for get_response_line"])
controller.safe_close()
# check that third 'test' wasn't sent, and nor was 'quit'
tc.assertListEqual(channel.engine.commands_handled,
[('test', ['ab']), ('error', []), ('test', [])])