16
16
from reportportal_client ._local import current
17
17
from reportportal_client .helpers import get_function_params , evaluate_status , \
18
18
timestamp
19
- from reportportal_client .static .defines import ItemStartType , NOT_FOUND
19
+ from reportportal_client .static .defines import NOT_FOUND
20
20
21
21
NESTED_STEP_ITEMS = ('step' , 'scenario' , 'before_class' , 'before_groups' ,
22
22
'before_method' , 'before_suite' , 'before_test' ,
@@ -43,7 +43,8 @@ def get_parent(self):
43
43
return self .__levels [- 1 ]
44
44
45
45
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 ):
47
48
return self .__levels .pop ()
48
49
49
50
def start_nested_step (self ,
@@ -60,10 +61,11 @@ def start_nested_step(self,
60
61
parent_item_id = parent_id )
61
62
62
63
def finish_nested_step (self ,
64
+ item_id ,
63
65
end_time ,
64
66
status = None ,
65
67
** kwargs ):
66
- parent_id = self .remove_parent ()
68
+ parent_id = self .remove_parent (item_id )
67
69
if parent_id is None :
68
70
return
69
71
self .client .finish_test_item (parent_id , end_time , status = status )
@@ -75,9 +77,10 @@ def __init__(self, name, params, status, rp_client):
75
77
self .params = params
76
78
self .status = status
77
79
self .client = rp_client if rp_client is not None else current ()
80
+ self .__item_id = None
78
81
79
82
def __enter__ (self ):
80
- self .client .step_reporter \
83
+ self .__item_id = self . client .step_reporter \
81
84
.start_nested_step (self .name , timestamp (), parameters = self .params )
82
85
logger .info ("Parameters: " + str (self .params ))
83
86
@@ -86,7 +89,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
86
89
if any ((exc_type , exc_val , exc_tb )):
87
90
step_status = 'FAILED'
88
91
self .client .step_reporter \
89
- .finish_nested_step (timestamp (),
92
+ .finish_nested_step (self . __item_id , timestamp (),
90
93
evaluate_status (self .status , step_status ))
91
94
92
95
def __call__ (self , func ):
0 commit comments