本文整理汇总了Python中uiautomator.Adb.device_serial方法的典型用法代码示例。如果您正苦于以下问题:Python Adb.device_serial方法的具体用法?Python Adb.device_serial怎么用?Python Adb.device_serial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uiautomator.Adb
的用法示例。
在下文中一共展示了Adb.device_serial方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_adb_cmd_server_host
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import device_serial [as 别名]
def test_adb_cmd_server_host(self):
adb = Adb(adb_server_host="localhost", adb_server_port=5037)
adb.adb = MagicMock()
adb.adb.return_value = "adb"
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
args = ["a", "b", "c"]
with patch("subprocess.Popen") as Popen:
os.name = "nt"
adb.raw_cmd(*args)
Popen.assert_called_once_with(
[adb.adb()] + args,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
adb = Adb(adb_server_host="test.com", adb_server_port=1000)
adb.adb = MagicMock()
adb.adb.return_value = "adb"
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
args = ["a", "b", "c"]
with patch("subprocess.Popen") as Popen:
os.name = "posix"
adb.raw_cmd(*args)
Popen.assert_called_once_with(
[" ".join([adb.adb()] + ["-H", "test.com", "-P", "1000"] + args)],
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
示例2: test_adb_cmd
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import device_serial [as 别名]
def test_adb_cmd(self):
adb = Adb()
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
adb.raw_cmd = MagicMock()
args = ["a", "b", "c"]
adb.cmd(*args)
adb.raw_cmd.assert_called_once_with("-s", adb.device_serial(), *args)
示例3: test_device_serial
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import device_serial [as 别名]
def test_device_serial(self):
with patch.dict('os.environ', {'ANDROID_SERIAL': "ABCDEF123456"}):
adb = Adb()
adb.devices = MagicMock()
adb.devices.return_value = {"ABCDEF123456": "device"}
self.assertEqual(adb.device_serial(), "ABCDEF123456")
with patch.dict('os.environ', {'ANDROID_SERIAL': "ABCDEF123456"}):
adb = Adb()
adb.devices = MagicMock()
adb.devices.return_value = {"ABCDEF123456": "device", "123456ABCDEF": "device"}
self.assertEqual(adb.device_serial(), "ABCDEF123456")
with patch.dict('os.environ', {'ANDROID_SERIAL': "HIJKLMN098765"}):
adb = Adb()
adb.devices = MagicMock()
adb.devices.return_value = {"ABCDEF123456": "device", "123456ABCDEF": "device"}
with self.assertRaises(EnvironmentError):
adb.device_serial()
with patch.dict('os.environ', {}, clear=True):
adb = Adb()
adb.devices = MagicMock()
adb.devices.return_value = {"ABCDEF123456": "device", "123456ABCDEF": "device"}
with self.assertRaises(EnvironmentError):
adb.device_serial()
with patch.dict('os.environ', {}, clear=True):
adb = Adb()
adb.devices = MagicMock()
adb.devices.return_value = {"ABCDEF123456": "device"}
print(adb.devices())
self.assertEqual(adb.device_serial(), "ABCDEF123456")
with self.assertRaises(EnvironmentError):
adb = Adb()
adb.devices = MagicMock()
adb.devices.return_value = {}
adb.device_serial()
示例4: adb
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import device_serial [as 别名]
class adb(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
self.instAdb=Adb()
self.devSerialNoms= self.instAdb.devices().keys()
self.devcount = len(self.devSerialNoms)
self.devSerial = self.instAdb.device_serial()
def getSerials(self):
return self.devSerialNoms
#return self.devSerialNoms
def getDeviceCount(self):
return self.devcount
def getSerial(self):
return self.devSerial
示例5: test_adb_cmd_server_host
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import device_serial [as 别名]
def test_adb_cmd_server_host(self):
adb = Adb(adb_server_host="localhost", adb_server_port=5037)
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
adb.raw_cmd = MagicMock()
args = ["a", "b", "c"]
adb.cmd(*args)
adb.raw_cmd.assert_called_once_with("-H", "localhost", "-P", "5037", "-s", "%s" % adb.device_serial(), *args)
adb = Adb(adb_server_host="localhost")
adb.device_serial = MagicMock()
adb.device_serial.return_value = "ANDROID_SERIAL"
adb.raw_cmd = MagicMock()
args = ["a", "b", "c"]
adb.cmd(*args)
adb.raw_cmd.assert_called_once_with("-H", "localhost", "-s", "%s" % adb.device_serial(), *args)
示例6: test_serial
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import device_serial [as 别名]
def test_serial(self):
serial = "abcdef1234567890"
adb = Adb(serial)
self.assertEqual(adb.default_serial, serial)
adb.devices = MagicMock()
adb.devices.return_value = [serial, "123456"]
self.assertEqual(adb.device_serial(), serial)
示例7: print
# 需要导入模块: from uiautomator import Adb [as 别名]
# 或者: from uiautomator.Adb import device_serial [as 别名]
from uiautomator import Device, Adb, AutomatorDevice
from Libs import SaveToLog as saveLog
from Libs import ModelInfo
import Libs.ClsKeyCode
instAdb=Adb()
devSerials= instAdb.devices().keys()
print(type(devSerials))
osType = sys.platform
sndLog = saveLog()
#sndLog = CLS("test", "test")
if len(devSerials) == 1:
devSerials = instAdb.device_serial()
mstrDevice = Device(devSerials)
mstrInfo = mstrDevice.info
else:
mstrDevSerial, slavDevSerial = devSerials
mstrDevice = Device(mstrDevSerial)
slvDevice = Device(slavDevSerial)
mstrInfo = mstrDevice.info
slvInfo = slvDevice.info
sndLog.SendToLog("start")
modinfo = ModelInfo(mstrInfo)