本文整理汇总了Python中uiautomator.AutomatorServer.start方法的典型用法代码示例。如果您正苦于以下问题:Python AutomatorServer.start方法的具体用法?Python AutomatorServer.start怎么用?Python AutomatorServer.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uiautomator.AutomatorServer
的用法示例。
在下文中一共展示了AutomatorServer.start方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_start_success
# 需要导入模块: from uiautomator import AutomatorServer [as 别名]
# 或者: from uiautomator.AutomatorServer import start [as 别名]
def test_start_success(self):
server = AutomatorServer()
server.push = MagicMock()
server.push.return_value = ["bundle.jar", "uiautomator-stub.jar"]
server.ping = MagicMock()
server.ping.return_value = "pong"
server.adb = MagicMock()
server.start()
server.adb.cmd.assert_valled_onec_with('shell', 'uiautomator', 'runtest', 'bundle.jar', 'uiautomator-stub.jar', '-c', 'com.github.uiautomatorstub.Stub')
示例2: test_start_error
# 需要导入模块: from uiautomator import AutomatorServer [as 别名]
# 或者: from uiautomator.AutomatorServer import start [as 别名]
def test_start_error(self):
server = AutomatorServer()
server.push = MagicMock()
server.push.return_value = ["bundle.jar", "uiautomator-stub.jar"]
server.ping = MagicMock()
server.ping.return_value = None
server.adb = MagicMock()
with patch("time.sleep"):
with self.assertRaises(IOError):
server.start()
示例3: test_start_forward_error
# 需要导入模块: from uiautomator import AutomatorServer [as 别名]
# 或者: from uiautomator.AutomatorServer import start [as 别名]
def test_start_forward_error(self):
server = AutomatorServer()
server.download_and_push = MagicMock()
server.download_and_push.return_value = ["bundle.jar", "uiautomator-stub.jar"]
with patch("uiautomator.adb") as adb:
adb.forward.return_value = 1
with patch.dict('os.environ', {'LOCAL_PORT': '9000', 'DEVICE_PORT': '9000'}):
with self.assertRaises(IOError):
server.start()
adb.forward.assert_called_once_with(9000, 9000)
示例4: test_start_success
# 需要导入模块: from uiautomator import AutomatorServer [as 别名]
# 或者: from uiautomator.AutomatorServer import start [as 别名]
def test_start_success(self):
server = AutomatorServer()
server.download_and_push = MagicMock()
server.download_and_push.return_value = ["bundle.jar", "uiautomator-stub.jar"]
server.ping = MagicMock()
server.ping.return_value = "pong"
with patch("uiautomator.adb") as adb:
adb.forward.return_value = 0
with patch.dict('os.environ', {'LOCAL_PORT': '9000', 'DEVICE_PORT': '9000'}):
server.start()
adb.cmd.assert_valled_onec_with('shell', 'uiautomator', 'runtest', 'bundle.jar', 'uiautomator-stub.jar', '-c', 'com.github.uiautomatorstub.Stub')
adb.forward.assert_called_once_with(9000, 9000)
示例5: test_auto_start
# 需要导入模块: from uiautomator import AutomatorServer [as 别名]
# 或者: from uiautomator.AutomatorServer import start [as 别名]
def test_auto_start(self):
with patch("uiautomator.JsonRPCClient") as JsonRPCClient:
JsonRPCClient.ping.return_value = None
server = AutomatorServer()
server.start = MagicMock()
server.stop = MagicMock()
server.jsonrpc
server.start.assert_called_once_with()
示例6: test_auto_start
# 需要导入模块: from uiautomator import AutomatorServer [as 别名]
# 或者: from uiautomator.AutomatorServer import start [as 别名]
def test_auto_start(self):
try:
import requests
except ImportError:
raise
with patch("uiautomator.JsonRPCMethod") as JsonRPCMethod:
# returns = [urllib2.URLError("error"), "ok"]
returns = [requests.exceptions.ConnectionError("error"), "ok"]
def side_effect():
result = returns.pop(0)
if isinstance(result, Exception):
raise result
return result
JsonRPCMethod.return_value.side_effect = side_effect
server = AutomatorServer()
server.start = MagicMock()
server.stop = MagicMock()
self.assertEqual("ok", server.jsonrpc.any_method())
server.start.assert_called_once_with(timeout=30)
with patch("uiautomator.JsonRPCMethod") as JsonRPCMethod:
returns = [requests.exceptions.ConnectionError("error"), "ok"]
# returns = [JsonRPCError(-32000-1, "error msg"), "ok"]
def side_effect():
result = returns.pop(0)
if isinstance(result, Exception):
raise result
return result
JsonRPCMethod.return_value.side_effect = side_effect
server = AutomatorServer()
server.start = MagicMock()
server.stop = MagicMock()
self.assertEqual("ok", server.jsonrpc.any_method())
server.start.assert_called_once_with(timeout=30)
with patch("uiautomator.JsonRPCMethod") as JsonRPCMethod:
JsonRPCMethod.return_value.side_effect = JsonRPCError(-32000-2, "error msg")
server = AutomatorServer()
server.start = MagicMock()
server.stop = MagicMock()
with self.assertRaises(JsonRPCError):
server.jsonrpc.any_method()
示例7: test_auto_start
# 需要导入模块: from uiautomator import AutomatorServer [as 别名]
# 或者: from uiautomator.AutomatorServer import start [as 别名]
def test_auto_start(self):
with patch.dict('os.environ', {'LOCAL_PORT': '9000', 'DEVICE_PORT': '9000'}):
with patch("uiautomator.JsonRPCClient") as JsonRPCClient:
JsonRPCClient.ping.return_value = None
server = AutomatorServer()
server.start = MagicMock()
server.jsonrpc
JsonRPCClient.assert_called_once_with(server.rpc_uri)
server.start.assert_called_once_with()
server.jsonrpc # second call will retrieve the stored obj
JsonRPCClient.assert_called_once_with(server.rpc_uri)