mirror of
https://github.com/appium/appium.git
synced 2026-01-14 06:10:01 -06:00
* add initial python sample
* add all of ios and android tests
* apply formatter
* add >=0.28 to avoid version error
* tweak versions of default OS
* convert some tests to unittest based ones
* use single quote mainly
* use {} format style for string
* use format syntax
* apply format and tweak assertions
* use is None
* use assert raise
* speficy a number of elements
* tweak exception
* move app path to helper
* tweak assertion conditions
* remove .close since with open() close file automatically
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import pytest
|
|
import datetime
|
|
import os
|
|
|
|
from helpers import ensure_dir
|
|
|
|
|
|
def pytest_configure(config):
|
|
if not hasattr(config, 'slaveinput'):
|
|
current_day = '{:%Y_%m_%d_%H_%S}'.format(datetime.datetime.now())
|
|
ensure_dir('results')
|
|
ensure_dir(os.path.join('slaveinput', current_day))
|
|
result_dir = os.path.join(os.path.dirname(__file__), 'results', current_day)
|
|
ensure_dir(result_dir)
|
|
result_dir_test_run = result_dir
|
|
ensure_dir(os.path.join(result_dir_test_run, 'screenshots'))
|
|
ensure_dir(os.path.join(result_dir_test_run, 'logcat'))
|
|
config.screen_shot_dir = os.path.join(result_dir_test_run, 'screenshots')
|
|
config.logcat_dir = os.path.join(result_dir_test_run, 'logcat')
|
|
|
|
|
|
class DeviceLogger:
|
|
def __init__(self, logcat_dir, screenshot_dir):
|
|
self.screenshot_dir = screenshot_dir
|
|
self.logcat_dir = logcat_dir
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
def device_logger(request):
|
|
logcat_dir = request.config.logcat_dir
|
|
screenshot_dir = request.config.screen_shot_dir
|
|
return DeviceLogger(logcat_dir, screenshot_dir)
|