1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- # coding: utf-8
- import adbutils
- import pytest
- import uiautomator2 as u2
- @pytest.fixture(scope="module")
- def d(device):
- _d = device
- _d.settings['operation_delay'] = (0.2, 0.2)
- _d.settings['operation_delay_methods'] = ['click', 'swipe']
- return _d
- @pytest.fixture
- def package_name():
- return "io.appium.android.apis"
- @pytest.fixture(scope="function")
- def dev(d: u2.Device, package_name) -> u2.Device: # type: ignore
- d.watcher.reset()
-
- d.app_start(package_name, stop=True)
- yield d
- # run parallel
- # py.test --tx "3*popen" --dist=load test_device.py -q --tb=line
- #def read_device_list() -> list:
- # return [v.serial for v in adbutils.adb.device_list()]
- #def pytest_configure(config):
- # # read device list if we are on the master
- # if not hasattr(config, "slaveinput"):
- # config.devlist = read_device_list()
- # def pytest_configure_node(node):
- # # the master for each node fills slaveinput dictionary
- # # which pytest-xdist will transfer to the subprocess
- # serial = node.slaveinput["serial"] = node.config.devlist.pop()
- # node.config.devlist.insert(0, serial)
- @pytest.fixture(scope="session")
- def device(request):
- return u2.connect()
- # slaveinput = getattr(request.config, "slaveinput", None)
- # if slaveinput is None: # single-process execution
- # serial = read_device_list()[0]
- # else: # running in a subprocess here
- # serial = slaveinput["serial"]
- # print("SERIAL:", serial)
- # return u2.connect(serial)
|