Skip to content

Commit

Permalink
chore: check code specification
Browse files Browse the repository at this point in the history
  • Loading branch information
DHpie committed Apr 14, 2022
1 parent 7a338d8 commit 68ba2bc
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 47 deletions.
3 changes: 2 additions & 1 deletion flybirds/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def runner(
),
processes: int = typer.Option(
4, "--processes", '-p',
help="Maximum number of processes. Default = 4"
help="Maximum number of processes. Default = 4. Effective when "
"test on web."
)
):
"""
Expand Down
4 changes: 2 additions & 2 deletions flybirds/cli/create_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create_demo():
"Please input your test platform?(Android/IOS/Web)"
)
if test_platform is None or test_platform.strip().lower() not in [
'android', 'ios', 'web']:
'android', 'ios', 'web']:
test_platform = 'android'
test_platform = test_platform.strip().lower()
user_dict['test_platform'] = test_platform
Expand Down Expand Up @@ -89,7 +89,7 @@ def create_demo():
"Please input your test browserType?(chromium/firefox/webkit)"
)
if browser_type is None or browser_type.strip().lower() not in [
'chromium', 'firefox', 'webkit']:
'chromium', 'firefox', 'webkit']:
browser_type = 'chromium'
browser_type = browser_type.strip().lower()
user_dict['browser_type'] = browser_type
Expand Down
4 changes: 2 additions & 2 deletions flybirds/cli/parse_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def parse_args(
:return:
"""
log.info(
f"flybirds cmd info: {feature_path} {tag} {report_format} {report_path}"
f" {define} {rerun} {es} {to_html} {run_at}"
f"flybirds cmd info: {feature_path} {tag} {report_format} "
f"{report_path} {define} {rerun} {es} {to_html} {run_at}"
)

check_workspace_args(feature_path)
Expand Down
2 changes: 1 addition & 1 deletion flybirds/core/config_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class WebConfig:
def __init__(self, user_data, config):
web_info = get_config(config, "web_info")
if web_info is None:
log.warn(f'[web_info] configuration of web_info is none.')
log.warn('[web_info] configuration of web_info is none.')
# default value
self.headless = True
self.browser_type = 'chromium'
Expand Down
2 changes: 0 additions & 2 deletions flybirds/core/plugin/plugins/default/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
from .web.screen import Screen
from .web.screen_record import ScreenRecordInfo
12 changes: 1 addition & 11 deletions flybirds/core/plugin/plugins/default/android/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

from flybirds.core.plugin.plugins.default.app_base_step import AppBaseStep
from flybirds.core.plugin.plugins.default.step.app \
import (install_app, uninstall_app, to_app_home, app_login, app_logout,
return_pre_page)
import (install_app, uninstall_app, return_pre_page)
from flybirds.core.plugin.plugins.default.step.schema import jump_to_page

__open__ = ["Step"]
Expand All @@ -23,15 +22,6 @@ def install_app(self, context, param):
def uninstall_app(self, context, param):
uninstall_app(context, param)

def to_app_home(self, context):
to_app_home(context)

def app_login(self, context, param1, param2):
app_login(context, param1, param2)

def app_logout(self, context):
app_logout(context)

def return_pre_page(self, context):
return_pre_page(context)

Expand Down
14 changes: 13 additions & 1 deletion flybirds/core/plugin/plugins/default/app_base_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import flybirds.core.plugin.plugins.default.step.attr as step_attr
import flybirds.core.plugin.plugins.default.step.click as step_click
import flybirds.core.plugin.plugins.default.step.common as step_common
import flybirds.core.plugin.plugins.default.step.page_show_adjust as step_adjust
import flybirds.core.plugin.plugins.default.step.page_show_adjust \
as step_adjust
import flybirds.core.plugin.plugins.default.step.record as step_record
import flybirds.core.plugin.plugins.default.step.swipe as step_swipe
import flybirds.core.plugin.plugins.default.step.verify as step_verify
from flybirds.core.plugin.plugins.default.step.app \
import (to_app_home, app_login, app_logout)
from flybirds.core.plugin.plugins.default.step.input import ele_input
from flybirds.core.plugin.plugins.default.step.position import (
position_not_change
Expand Down Expand Up @@ -116,3 +119,12 @@ def wait_ele_appear(self, context, param):

def exist_ele(self, context, param):
step_verify.exist_ele(context, param)

def to_app_home(self, context):
to_app_home(context)

def app_login(self, context, param1, param2):
app_login(context, param1, param2)

def app_logout(self, context):
app_logout(context)
8 changes: 4 additions & 4 deletions flybirds/core/plugin/plugins/default/base_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import \
flybirds.core.plugin.plugins.default.ui_driver.poco.poco_attr as poco_attr
import \
flybirds.core.plugin.plugins.default.ui_driver.poco.poco_click as poco_click
import flybirds.core.plugin.plugins.default.ui_driver.poco.poco_click \
as poco_click
import flybirds.core.plugin.plugins.default.ui_driver.poco.poco_ele as poco_ele
import \
flybirds.core.plugin.plugins.default.ui_driver.poco.poco_findsnap \
Expand All @@ -18,8 +18,8 @@
import \
flybirds.core.plugin.plugins.default.ui_driver.poco.poco_selector \
as poco_selector
import \
flybirds.core.plugin.plugins.default.ui_driver.poco.poco_swipe as poco_swipe
import flybirds.core.plugin.plugins.default.ui_driver.poco.poco_swipe \
as poco_swipe
import \
flybirds.core.plugin.plugins.default.ui_driver.poco.poco_text as poco_text
import \
Expand Down
4 changes: 2 additions & 2 deletions flybirds/core/plugin/plugins/default/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def screen_link_to_behave(scenario, step_index, tag=None):
screenshot address and linked to the <scr> tag
The label information is placed in the description of the scene,
and the json report is processed after all the runs are finished,
and the <scr> information in the description is converted into embeddings
information in the step.
and the <scr> information in the description is converted into
embeddings information in the step.
"""
feature_name = file_helper.valid_file_name(scenario.feature.name)
scenario_name = file_helper.valid_file_name(scenario.name)
Expand Down
14 changes: 7 additions & 7 deletions flybirds/core/plugin/plugins/default/screen_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,20 @@ def start_record(self, timeout, bit_rate_level=1, bit_rate=None):
cmd = "{} -s {} shell screenrecord --bugreport " \
"--size {}x{} --time-limit {} --bit-rate {} " \
"--verbose sdcard/flybirds.mp4".format(airtest_adb_path,
device_id,
screen_size[0],
screen_size[1],
timeout, bit_rate)
device_id,
screen_size[0],
screen_size[1],
timeout, bit_rate)
else:
cmd = "{} -s {} shell screenrecord" \
" --size {}x{} " \
"--time-limit {} " \
"--bit-rate {}" \
" --verbose " \
"sdcard/flybirds.mp4".format(airtest_adb_path, device_id,
screen_size[0],
screen_size[1], timeout,
bit_rate)
screen_size[0],
screen_size[1], timeout,
bit_rate)

proc = cmd_helper.create_sub_process(cmd)
message = ""
Expand Down
3 changes: 2 additions & 1 deletion flybirds/core/plugin/plugins/default/step/click.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Step implement of element click.
"""
import flybirds.core.global_resource as gr
import flybirds.core.plugin.plugins.default.ui_driver.poco.findsnap as find_snap
import flybirds.core.plugin.plugins.default.ui_driver.poco.findsnap \
as find_snap
import flybirds.utils.dsl_helper as dsl_helper
from flybirds.core.global_context import GlobalContext as g_Context

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"""
Convert poco object
"""
import flybirds.core.plugin.plugins.default.ui_driver.poco.parse_selector as msd
import flybirds.core.plugin.plugins.default.ui_driver.poco.parse_selector \
as msd
import flybirds.core.plugin.plugins.default.ui_driver.poco.poco_selector as pc
import flybirds.utils.snippet as snippet
from flybirds.core.global_context import GlobalContext as g_Context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import time

import flybirds.core.global_resource as gr
import flybirds.core.plugin.plugins.default.ui_driver.poco.findsnap as find_snap
import flybirds.core.plugin.plugins.default.ui_driver.poco.findsnap \
as find_snap
import flybirds.core.plugin.plugins.default.ui_driver.poco.poco_manage as pm
import flybirds.utils.flybirds_log as log
from flybirds.core.exceptions import FlybirdEleExistsException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
Poco manage api
"""
import flybirds.core.plugin.plugins.default.ui_driver.poco.parse_path as parse
import flybirds.core.plugin.plugins.default.ui_driver.poco.parse_selector as msd
import flybirds.core.plugin.plugins.default.ui_driver.poco.parse_selector \
as msd
import flybirds.core.plugin.plugins.default.ui_driver.poco.poco_selector as pc
from flybirds.core.global_context import GlobalContext as g_context

Expand Down
2 changes: 1 addition & 1 deletion flybirds/core/plugin/plugins/default/web/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def ele_select(self, context, selector, option_str):
log.info(f'[ele_select] select option[{option_str}] success.')
except FlybirdsVerifyEleException as fe:
raise fe
except Exception as e:
except Exception:
# select by value
log.warn(f'[ele_select] retry select option[{option_str}].')
locator.select_option(option_str)
Expand Down
2 changes: 1 addition & 1 deletion flybirds/core/plugin/plugins/default/web/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def sleep(self, context, param):
if is_number(param):
self.page.wait_for_timeout(float(param) * 1000)
else:
log.warn(f"default wait for timeout!")
log.warn("default wait for timeout!")
self.page.wait_for_timeout(3 * 1000)

def cur_page_equal(self, context, param):
Expand Down
1 change: 0 additions & 1 deletion flybirds/core/script_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ def __init__(self):
if os.path.exists(tag_provider_path):
tag_provider_path_import_path = "tag_provider"
self.tag_provider = __import__(tag_provider_path_import_path)

6 changes: 1 addition & 5 deletions flybirds/report/fail_feature_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,7 @@ def failed_rerun(rerun_cmd_str: str, rerun_feature_path, processes,


def parallel_rerun(rerun_cmd_str: str, rerun_feature_path, processes):
log.info(f'parallel_rerun start!')
log.info(f'[parallel_rerun] processes num: {processes}')
log.info(f'[parallel_rerun] rerun_feature_path: {rerun_feature_path}')
log.info(f'[parallel_rerun] rerun_cmd_str: \n\n{rerun_cmd_str}\n\n')

log.info('parallel_rerun start!')
dry_cmd = f'behave {rerun_feature_path} -d -k -f json --no-summary'
features = get_features_num(dry_cmd)
log.info(f'[parallel_rerun] features num: {len(features)}')
Expand Down
3 changes: 2 additions & 1 deletion flybirds/report/parallel_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def parallel_run(context):

if parsed_tags and len(parsed_tags) > 0:
# -k, --no-skipped
cmd = f'behave {feature_path} {" ".join(parsed_tags)} -d -k -f json --no-summary'
cmd = f'behave {feature_path} {" ".join(parsed_tags)} -d -k -f json ' \
f'--no-summary'
else:
cmd = f'behave {feature_path} -d -k -f json --no-summary'
features = get_features_num(cmd)
Expand Down
2 changes: 1 addition & 1 deletion flybirds/utils/file_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_json_from_file_path(path):
f = open(path, "r", errors='ignore')
json_str = f.read().strip().replace('\r\n', '\\r\\n')
result = json.loads(json_str, strict=False)
except JSONDecodeError as e:
except JSONDecodeError:
log.warn('get_json_from_file_path has error.')
finally:
if f:
Expand Down

0 comments on commit 68ba2bc

Please sign in to comment.