當前位置: 首頁>>代碼示例>>Python>>正文


Python Gtp_controller.do_command方法代碼示例

本文整理匯總了Python中gomill.gtp_controller.Gtp_controller.do_command方法的典型用法代碼示例。如果您正苦於以下問題:Python Gtp_controller.do_command方法的具體用法?Python Gtp_controller.do_command怎麽用?Python Gtp_controller.do_command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gomill.gtp_controller.Gtp_controller的用法示例。


在下文中一共展示了Gtp_controller.do_command方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_controller_first_command_error

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_command [as 別名]
def test_controller_first_command_error(tc):
    channel = gtp_engine_fixtures.get_test_channel()
    controller = Gtp_controller(channel, 'player test')
    with tc.assertRaises(BadGtpResponse) as ar:
        controller.do_command("error")
    tc.assertEqual(
        str(ar.exception),
        "failure response from first command (error) to player test:\n"
        "normal error")
    tc.assertListEqual(controller.retrieve_error_messages(), [])
開發者ID:cjlarose,項目名稱:gomill,代碼行數:12,代碼來源:gtp_controller_tests.py

示例2: test_controller_response_protocol_error

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_command [as 別名]
def test_controller_response_protocol_error(tc):
    channel = gtp_engine_fixtures.get_test_channel()
    controller = Gtp_controller(channel, 'player test')
    tc.assertEqual(controller.do_command("test"), "test response")
    tc.assertFalse(controller.channel_is_bad)
    channel.force_next_response = "# error\n\n"
    with tc.assertRaises(GtpProtocolError) as ar:
        controller.do_command("test")
    tc.assertEqual(
        str(ar.exception),
        "GTP protocol error reading response to 'test' from player test:\n"
        "no success/failure indication from engine: first line is `# error`")
    tc.assertTrue(controller.channel_is_bad)
    tc.assertListEqual(controller.retrieve_error_messages(), [])
開發者ID:cjlarose,項目名稱:gomill,代碼行數:16,代碼來源:gtp_controller_tests.py

示例3: test_controller_response_transport_error

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_command [as 別名]
def test_controller_response_transport_error(tc):
    channel = gtp_engine_fixtures.get_test_channel()
    controller = Gtp_controller(channel, 'player test')
    tc.assertFalse(controller.channel_is_bad)
    channel.fail_next_response = True
    with tc.assertRaises(GtpTransportError) as ar:
        controller.do_command("test")
    tc.assertEqual(
        str(ar.exception),
        "transport error reading response to first command (test) "
        "from player test:\n"
        "forced failure for get_response_line")
    tc.assertTrue(controller.channel_is_bad)
    tc.assertListEqual(controller.retrieve_error_messages(), [])
開發者ID:cjlarose,項目名稱:gomill,代碼行數:16,代碼來源:gtp_controller_tests.py

示例4: test_controller_alt_exit

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_command [as 別名]
def test_controller_alt_exit(tc):
    channel = gtp_engine_fixtures.get_test_channel()
    channel.engine_exit_breaks_commands = False
    controller = Gtp_controller(channel, 'player test')
    controller.do_command("quit")
    tc.assertFalse(controller.channel_is_bad)
    with tc.assertRaises(GtpChannelClosed) as ar:
        controller.do_command("test")
    tc.assertEqual(str(ar.exception),
                   "error reading response to 'test' from player test:\n"
                   "engine has closed the response channel")
    tc.assertTrue(controller.channel_is_bad)
    controller.close()
    tc.assertListEqual(controller.retrieve_error_messages(), [])
開發者ID:cjlarose,項目名稱:gomill,代碼行數:16,代碼來源:gtp_controller_tests.py

示例5: test_controller_safe_close_after_error

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_command [as 別名]
def test_controller_safe_close_after_error(tc):
    channel = gtp_engine_fixtures.get_test_channel()
    controller = Gtp_controller(channel, 'player test')
    tc.assertEqual(controller.do_command("test"), "test response")
    tc.assertFalse(controller.channel_is_bad)
    channel.force_next_response = "# error\n\n"
    with tc.assertRaises(GtpProtocolError) as ar:
        controller.do_command("test")
    tc.assertTrue(controller.channel_is_bad)
    # doesn't send quit when channel_is_bad
    controller.safe_close()
    tc.assertTrue(controller.channel_is_closed)
    tc.assertTrue(controller.channel.is_closed)
    tc.assertListEqual(channel.engine.commands_handled,
                       [('test', []), ('test', [])])
    tc.assertListEqual(controller.retrieve_error_messages(), [])
開發者ID:cjlarose,項目名稱:gomill,代碼行數:18,代碼來源:gtp_controller_tests.py

示例6: test_controller

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_command [as 別名]
def test_controller(tc):
    channel = gtp_engine_fixtures.get_test_channel()
    controller = Gtp_controller(channel, 'player test')
    tc.assertEqual(controller.name, 'player test')
    tc.assertIs(controller.channel, channel)
    tc.assertFalse(controller.channel_is_bad)

    tc.assertEqual(controller.do_command("test", "ab", "cd"), "args: ab cd")
    with tc.assertRaises(BadGtpResponse) as ar:
        controller.do_command("error")
    tc.assertEqual(ar.exception.gtp_error_message, "normal error")
    tc.assertEqual(ar.exception.gtp_command, "error")
    tc.assertSequenceEqual(ar.exception.gtp_arguments, [])
    tc.assertEqual(str(ar.exception),
                   "failure response from 'error' to player test:\n"
                   "normal error")
    with tc.assertRaises(BadGtpResponse) as ar:
        controller.do_command("fatal")
    tc.assertFalse(controller.channel_is_bad)

    with tc.assertRaises(GtpChannelClosed) as ar:
        controller.do_command("test")
    tc.assertEqual(str(ar.exception),
                   "error sending 'test' to player test:\n"
                   "engine has closed the command channel")
    tc.assertTrue(controller.channel_is_bad)
    controller.close()
    tc.assertListEqual(controller.retrieve_error_messages(), [])
開發者ID:cjlarose,項目名稱:gomill,代碼行數:30,代碼來源:gtp_controller_tests.py

示例7: test_gtp_aliases

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_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")
開發者ID:cjlarose,項目名稱:gomill,代碼行數:21,代碼來源:gtp_controller_tests.py

示例8: test_subprocess_channel_with_controller

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_command [as 別名]
def test_subprocess_channel_with_controller(tc):
    # Also tests that leaving 'env' and 'cwd' unset works
    fx = gtp_engine_fixtures.State_reporter_fixture(tc)
    channel = gtp_controller.Subprocess_gtp_channel(fx.cmd, stderr=fx.devnull)
    controller = Gtp_controller(channel, 'subprocess test')
    tc.assertEqual(controller.do_command("tell"),
                   "cwd: %s\nGOMILL_TEST:None" % os.getcwd())
    controller.close()
    tc.assertEqual(channel.exit_status, 0)
    rusage = channel.resource_usage
    tc.assertTrue(hasattr(rusage, 'ru_utime'))
開發者ID:cjlarose,項目名稱:gomill,代碼行數:13,代碼來源:gtp_controller_tests.py

示例9: test_controller_safe_close

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_command [as 別名]
def test_controller_safe_close(tc):
    channel = gtp_engine_fixtures.get_test_channel()
    controller = Gtp_controller(channel, 'player test')
    tc.assertFalse(controller.channel_is_closed)
    tc.assertEqual(controller.do_command("test"), "test response")
    tc.assertFalse(controller.channel_is_closed)
    tc.assertFalse(controller.channel.is_closed)
    controller.safe_close()
    tc.assertTrue(controller.channel_is_closed)
    tc.assertTrue(controller.channel.is_closed)
    tc.assertListEqual(channel.engine.commands_handled,
                       [('test', []), ('quit', [])])
    # safe to call twice
    controller.safe_close()
    tc.assertListEqual(controller.retrieve_error_messages(), [])
開發者ID:cjlarose,項目名稱:gomill,代碼行數:17,代碼來源:gtp_controller_tests.py

示例10: test_controller_close

# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import do_command [as 別名]
def test_controller_close(tc):
    channel = gtp_engine_fixtures.get_test_channel()
    controller = Gtp_controller(channel, 'player test')
    tc.assertFalse(controller.channel_is_closed)
    tc.assertEqual(controller.do_command("test"), "test response")
    tc.assertFalse(controller.channel_is_closed)
    tc.assertFalse(controller.channel.is_closed)
    controller.close()
    tc.assertTrue(controller.channel_is_closed)
    tc.assertTrue(controller.channel.is_closed)
    tc.assertRaisesRegexp(StandardError, "^channel is closed$",
                          controller.do_command, "test")
    tc.assertRaisesRegexp(StandardError, "^channel is closed$",
                          controller.close)
    tc.assertListEqual(controller.retrieve_error_messages(), [])
開發者ID:cjlarose,項目名稱:gomill,代碼行數:17,代碼來源:gtp_controller_tests.py


注:本文中的gomill.gtp_controller.Gtp_controller.do_command方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。