本文整理匯總了Python中gomill.gtp_controller.Gtp_controller.safe_close方法的典型用法代碼示例。如果您正苦於以下問題:Python Gtp_controller.safe_close方法的具體用法?Python Gtp_controller.safe_close怎麽用?Python Gtp_controller.safe_close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gomill.gtp_controller.Gtp_controller
的用法示例。
在下文中一共展示了Gtp_controller.safe_close方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_safe_do_command_closed_channel
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_close [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_controller_safe_close_with_error_from_close
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_close [as 別名]
def test_controller_safe_close_with_error_from_close(tc):
channel = gtp_engine_fixtures.get_test_channel()
controller = Gtp_controller(channel, 'player test')
channel.fail_close = True
controller.safe_close()
tc.assertTrue(controller.channel_is_closed)
tc.assertListEqual(channel.engine.commands_handled,
[('quit', [])])
tc.assertListEqual(
controller.retrieve_error_messages(),
["error closing player test:\n"
"forced failure for close"])
示例3: test_controller_safe_close_with_error_from_quit
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_close [as 別名]
def test_controller_safe_close_with_error_from_quit(tc):
channel = gtp_engine_fixtures.get_test_channel()
controller = Gtp_controller(channel, 'player test')
channel.force_next_response = "# error\n\n"
controller.safe_close()
tc.assertTrue(controller.channel_is_closed)
tc.assertTrue(controller.channel.is_closed)
tc.assertListEqual(channel.engine.commands_handled,
[('quit', [])])
tc.assertListEqual(
controller.retrieve_error_messages(),
["GTP protocol error reading response to first command (quit) "
"from player test:\n"
"no success/failure indication from engine: first line is `# error`"])
示例4: test_controller_safe_close_with_failure_response_from_quit
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_close [as 別名]
def test_controller_safe_close_with_failure_response_from_quit(tc):
channel = gtp_engine_fixtures.get_test_channel()
controller = Gtp_controller(channel, 'player test')
channel.engine.force_error("quit")
controller.safe_close()
tc.assertTrue(controller.channel_is_closed)
tc.assertTrue(controller.channel.is_closed)
tc.assertListEqual(channel.engine.commands_handled,
[('quit', [])])
error_messages = controller.retrieve_error_messages()
tc.assertEqual(len(error_messages), 1)
tc.assertEqual(
error_messages[0],
"failure response from first command (quit) to player test:\n"
"handler forced to fail")
示例5: test_controller_safe_close
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_close [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(), [])
示例6: test_controller_safe_close_after_error
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_close [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(), [])
示例7: test_safe_do_command
# 需要導入模塊: from gomill.gtp_controller import Gtp_controller [as 別名]
# 或者: from gomill.gtp_controller.Gtp_controller import safe_close [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', [])])