本文整理匯總了Python中gomill.gtp_controller.Gtp_controller.known_command方法的典型用法代碼示例。如果您正苦於以下問題:Python Gtp_controller.known_command方法的具體用法?Python Gtp_controller.known_command怎麽用?Python Gtp_controller.known_command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gomill.gtp_controller.Gtp_controller
的用法示例。
在下文中一共展示了Gtp_controller.known_command方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_known_command
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import known_command [as 別名]
def test_known_command(tc):
channel = gtp_engine_fixtures.get_test_channel()
controller = Gtp_controller(channel, 'kc test')
tc.assertTrue(controller.known_command("test"))
tc.assertFalse(controller.known_command("nonesuch"))
tc.assertTrue(controller.known_command("test"))
tc.assertFalse(controller.known_command("nonesuch"))
示例2: test_known_command_2
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import known_command [as 別名]
def test_known_command_2(tc):
# Checking that known_command caches its responses
# and that it treats an error or unknown value the same as 'false'.
channel = Preprogrammed_gtp_channel(
"= true\n\n= absolutely not\n\n? error\n\n# unreached\n\n")
controller = Gtp_controller(channel, 'kc2 test')
tc.assertTrue(controller.known_command("one"))
tc.assertFalse(controller.known_command("two"))
tc.assertFalse(controller.known_command("three"))
tc.assertTrue(controller.known_command("one"))
tc.assertFalse(controller.known_command("two"))
tc.assertEqual(
channel.get_command_stream(),
"known_command one\nknown_command two\nknown_command three\n")
示例3: test_gtp_aliases
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import known_command [as 別名]
def test_gtp_aliases(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.known_command("test"), True)
tc.assertIs(controller.known_command("aliased"), True)
tc.assertIs(controller.known_command("nonesuch"), False)
tc.assertIs(controller.known_command("test"), True)
tc.assertIs(controller.known_command("aliased"), True)
tc.assertIs(controller.known_command("nonesuch"), False)
tc.assertEqual(controller.do_command("test"), "test response")
tc.assertEqual(controller.do_command("aliased"), "test response")
with tc.assertRaises(BadGtpResponse) as ar:
controller.do_command("aliased2")
tc.assertEqual(ar.exception.gtp_error_message, "unknown command")
tc.assertEqual(ar.exception.gtp_command, "nonesuch")