本文整理汇总了Python中robot.api.logger.warn方法的典型用法代码示例。如果您正苦于以下问题:Python logger.warn方法的具体用法?Python logger.warn怎么用?Python logger.warn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类robot.api.logger
的用法示例。
在下文中一共展示了logger.warn方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import warn [as 别名]
def __init__(self, *args):
self.builtin = BuiltIn()
logger.debug("initializing PageObjects...")
importer = robot.utils.Importer()
for file_path in args:
try:
importer.import_class_or_module_by_path(os.path.abspath(file_path))
logger.debug("imported page object {}".format(file_path))
except Exception as e:
logger.warn(str(e))
self.current_page_object = None
# Start with this library at the front of the library search order;
# that may change as page objects are loaded.
try:
self.builtin.set_library_search_order("PageObjects")
except RobotNotRunningError:
# this should only happen when trying to load this library
# via the robot_libdoc task, in which case we don't care
# whether this throws an error or not.
pass
示例2: set_confidence
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import warn [as 别名]
def set_confidence(self, new_confidence):
'''Sets the accuracy when finding images.
``new_confidence`` is a decimal number between 0 and 1 inclusive.
See `Confidence level` about additional dependencies that needs to be
installed before this keyword has any effect.
'''
if new_confidence is not None:
try:
new_confidence = float(new_confidence)
if not 1 >= new_confidence >= 0:
LOGGER.warn('Unable to set confidence to {}. Value '
'must be between 0 and 1, inclusive.'
.format(new_confidence))
else:
self.confidence = new_confidence
except TypeError as err:
LOGGER.warn("Can't set confidence to {}".format(new_confidence))
else:
self.confidence = None
示例3: set_mouse_location
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import warn [as 别名]
def set_mouse_location(self, x, y):
"""Sets mouse position to (``x``, ``y``).
Position is relative to application window top left.
"""
window_location = self.state.window.Bounds.TopLeft
x_target = int(x) + window_location.X
y_target = int(y) + window_location.Y
point = Point(x_target, y_target)
Mouse.Instance.Location = point
if int(x_target) != int(Mouse.Instance.Location.X):
logger.warn(
"Mouse X position tried to be set outside of the screen. Wanted: {} result: {}".format(
x_target, Mouse.Instance.Location.X
),
True,
)
if int(y_target) != int(Mouse.Instance.Location.Y):
logger.warn(
"Mouse Y position tried to be set outside of the screen. Wanted: {} result: {}".format(
y_target, Mouse.Instance.Location.Y
),
True,
)
示例4: end_test
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import warn [as 别名]
def end_test(self, name: str, attributes: JsonDict) -> None:
""" Update test case in TestRail.
*Args:* \n
_name_ - name of test case in Robot Framework;\n
_attributes_ - attributes of test case in Robot Framework.
"""
tags_value = self._get_tags_value(attributes['tags'])
case_id = tags_value['testrailid']
if not case_id:
logger.warn(f"[TestRailListener] No case_id presented for test_case {name}.")
return
if 'skipped' in [tag.lower() for tag in attributes['tags']]:
logger.warn(f"[TestRailListener] SKIPPED test case \"{name}\" with testrailId={case_id} "
"will not be posted to Testrail")
return
# Update test case
if self.update:
references = tags_value['references']
self._update_case_description(attributes, case_id, name, references)
# Send test results
defects = tags_value['defects']
old_test_status_id = self.tr_client.get_test_status_id_by_case_id(self.run_id, case_id)
test_result = self._prepare_test_result(attributes, defects, old_test_status_id, case_id)
try:
self.tr_client.add_result_for_case(self.run_id, case_id, test_result)
except requests.HTTPError as error:
logger.error(f"[TestRailListener] http error on case_id = {case_id}\n{error}")
示例5: set_screenshot_folder
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import warn [as 别名]
def set_screenshot_folder(self, path):
"""Set a folder to keep the html files generated by the `Take Screenshot` keyword.
Example:
| Set Screenshot Folder | C:\\\Temp\\\Images |
"""
if os.path.exists(os.path.normpath(os.path.join(self.output_folder, path))):
self.imgfolder = path
else:
logger.error('Given screenshots path "%s" does not exist' % path)
logger.warn('Screenshots will be saved in "%s"' % self.imgfolder)
示例6: _run_on_failure
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import warn [as 别名]
def _run_on_failure(self):
if not self.keyword_on_failure:
return
try:
BuiltIn().run_keyword(self.keyword_on_failure)
except Exception as e:
LOGGER.debug(e)
LOGGER.warn('Failed to take a screenshot. '
'Is Robot Framework running?')
示例7: _warn
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import warn [as 别名]
def _warn(self, message):
if self._log_level in self.LOG_LEVEL_WARN:
logger.warn(message)
示例8: _warn
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import warn [as 别名]
def _warn(self, message):
logger.warn(message)
示例9: _instantiate
# 需要导入模块: from robot.api import logger [as 别名]
# 或者: from robot.api.logger import warn [as 别名]
def _instantiate(self, request, response, validate_schema=True):
try:
response_body = response.json()
except ValueError:
response_body = response.text
if response_body:
logger.warn(
"Response body content is not JSON. "
+ "Content-Type is: %s" % response.headers["Content-Type"]
)
response = {
"seconds": response.elapsed.microseconds / 1000 / 1000,
"status": response.status_code,
"body": response_body,
"headers": dict(response.headers),
}
schema = deepcopy(self.schema)
schema["title"] = "%s %s" % (request["method"], request["url"])
try:
schema["description"] = "%s: %s" % (
BuiltIn().get_variable_value("${SUITE NAME}"),
BuiltIn().get_variable_value("${TEST NAME}"),
)
except RobotNotRunningError:
schema["description"] = ""
request_properties = schema["properties"]["request"]["properties"]
response_properties = schema["properties"]["response"]["properties"]
if validate_schema:
if request_properties:
self._validate_schema(request_properties, request)
if response_properties:
self._validate_schema(response_properties, response)
request_properties["body"] = self._new_schema(request["body"])
request_properties["query"] = self._new_schema(request["query"])
response_properties["body"] = self._new_schema(response["body"])
if "default" in schema and schema["default"]:
self._add_defaults_to_schema(schema, response)
return {
"request": request,
"response": response,
"schema": schema,
"spec": self.spec,
}