Skip to content

Commit

Permalink
Some format update
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Oct 16, 2024
1 parent 3a82a3d commit f963b72
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions reportportal_client/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,7 @@ def __init__(self, rp_client):
"""
self.client = rp_client

def start_nested_step(self,
name,
start_time,
parameters=None,
**kwargs):
def start_nested_step(self, name, start_time, parameters=None, **_):
"""Start Nested Step on ReportPortal.
:param name: Nested Step name
Expand All @@ -80,16 +76,10 @@ def start_nested_step(self,
parent_id = self.client.current_item()
if not parent_id:
return
return self.client.start_test_item(name, start_time, 'step',
has_stats=False,
parameters=parameters,
parent_item_id=parent_id)

def finish_nested_step(self,
item_id,
end_time,
status=None,
**kwargs):
return self.client.start_test_item(
name, start_time, 'step', has_stats=False, parameters=parameters, parent_item_id=parent_id)

def finish_nested_step(self, item_id, end_time, status=None, **_):
"""Finish a Nested Step on ReportPortal.
:param item_id: Nested Step item ID
Expand Down Expand Up @@ -125,16 +115,14 @@ def __enter__(self):
rp_client = self.client or current()
if not rp_client:
return
self.__item_id = rp_client.step_reporter \
.start_nested_step(self.name, timestamp(), parameters=self.params)
self.__item_id = rp_client.step_reporter.start_nested_step(self.name, timestamp(), parameters=self.params)
if self.params:
param_list = [
str(key) + ": " + str(value)
for key, value in sorted(self.params.items())
]
param_str = 'Parameters: ' + '; '.join(param_list)
rp_client.log(timestamp(), param_str, level='INFO',
item_id=self.__item_id)
rp_client.log(timestamp(), param_str, level='INFO', item_id=self.__item_id)

def __exit__(self, exc_type, exc_val, exc_tb):
"""Exit the runtime context related to this object."""
Expand All @@ -148,8 +136,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
step_status = self.status
if any((exc_type, exc_val, exc_tb)):
step_status = 'FAILED'
rp_client.step_reporter \
.finish_nested_step(self.__item_id, timestamp(), step_status)
rp_client.step_reporter.finish_nested_step(self.__item_id, timestamp(), step_status)

def __call__(self, func):
"""Wrap and call a function reference.
Expand Down

0 comments on commit f963b72

Please sign in to comment.