Skip to content

Commit 1078905

Browse files
committed
Fixes
1 parent b434e7f commit 1078905

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

reportportal_client/steps/__init__.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from reportportal_client._local import current
1717
from reportportal_client.helpers import get_function_params, evaluate_status, \
1818
timestamp
19-
from reportportal_client.static.defines import ItemStartType, NOT_FOUND
19+
from reportportal_client.static.defines import NOT_FOUND
2020

2121
NESTED_STEP_ITEMS = ('step', 'scenario', 'before_class', 'before_groups',
2222
'before_method', 'before_suite', 'before_test',
@@ -43,7 +43,8 @@ def get_parent(self):
4343
return self.__levels[-1]
4444

4545
def remove_parent(self, parent_id=None):
46-
if len(self.__levels) > 0 and self.__levels[-1] == parent_id:
46+
if len(self.__levels) > 0 \
47+
and (parent_id is None or self.__levels[-1] == parent_id):
4748
return self.__levels.pop()
4849

4950
def start_nested_step(self,
@@ -60,10 +61,11 @@ def start_nested_step(self,
6061
parent_item_id=parent_id)
6162

6263
def finish_nested_step(self,
64+
item_id,
6365
end_time,
6466
status=None,
6567
**kwargs):
66-
parent_id = self.remove_parent()
68+
parent_id = self.remove_parent(item_id)
6769
if parent_id is None:
6870
return
6971
self.client.finish_test_item(parent_id, end_time, status=status)
@@ -75,9 +77,10 @@ def __init__(self, name, params, status, rp_client):
7577
self.params = params
7678
self.status = status
7779
self.client = rp_client if rp_client is not None else current()
80+
self.__item_id = None
7881

7982
def __enter__(self):
80-
self.client.step_reporter \
83+
self.__item_id = self.client.step_reporter \
8184
.start_nested_step(self.name, timestamp(), parameters=self.params)
8285
logger.info("Parameters: " + str(self.params))
8386

@@ -86,7 +89,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
8689
if any((exc_type, exc_val, exc_tb)):
8790
step_status = 'FAILED'
8891
self.client.step_reporter \
89-
.finish_nested_step(timestamp(),
92+
.finish_nested_step(self.__item_id, timestamp(),
9093
evaluate_status(self.status, step_status))
9194

9295
def __call__(self, func):

reportportal_client/steps/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class StepReporter:
3535
**kwargs: Any) -> Text: ...
3636

3737
def finish_nested_step(self,
38+
item_id: Text,
3839
end_time: Text,
3940
status: Text,
4041
**kwargs: Any) -> None: ...

0 commit comments

Comments
 (0)