@@ -42,6 +42,7 @@ def test_my_nested_step():
4242 pass
4343
4444"""
45+ from datetime import datetime , timezone
4546from functools import wraps
4647from typing import Any , Callable , Optional , TypeVar , Union
4748
@@ -52,7 +53,7 @@ def test_my_nested_step():
5253
5354# noinspection PyProtectedMember
5455from reportportal_client ._internal .local import current
55- from reportportal_client .helpers import get_function_params , timestamp
56+ from reportportal_client .helpers import get_function_params
5657
5758NESTED_STEP_ITEMS = (
5859 "step" ,
@@ -88,7 +89,11 @@ def __init__(self, rp_client: "rp.RP"):
8889 self .client = rp_client
8990
9091 def start_nested_step (
91- self , name : str , start_time : str , parameters : Optional [dict [str , Any ]] = None , ** _ : dict [str , Any ]
92+ self ,
93+ name : str ,
94+ start_time : Union [str , datetime ],
95+ parameters : Optional [dict [str , Any ]] = None ,
96+ ** _ : dict [str , Any ],
9297 ) -> Union [Optional [str ], Task [Optional [str ]]]:
9398 """Start Nested Step on ReportPortal.
9499
@@ -106,7 +111,7 @@ def start_nested_step(
106111 def finish_nested_step (
107112 self ,
108113 item_id : Union [str , Task [Optional [str ]]],
109- end_time : str ,
114+ end_time : Union [ str , datetime ] ,
110115 status : Optional [str ] = None ,
111116 ** _ : dict [str , Any ],
112117 ) -> Union [Optional [str ], Task [Optional [str ]]]:
@@ -151,11 +156,13 @@ def __enter__(self) -> None:
151156 rp_client = self .client or current ()
152157 if not rp_client :
153158 return
154- self .__item_id = rp_client .step_reporter .start_nested_step (self .name , timestamp (), parameters = self .params )
159+ self .__item_id = rp_client .step_reporter .start_nested_step (
160+ self .name , datetime .now (tz = timezone .utc ), parameters = self .params
161+ )
155162 if self .params :
156163 param_list = [str (key ) + ": " + str (value ) for key , value in sorted (self .params .items ())]
157164 param_str = "Parameters: " + "; " .join (param_list )
158- rp_client .log (timestamp ( ), param_str , level = "INFO" , item_id = self .__item_id )
165+ rp_client .log (datetime . now ( tz = timezone . utc ), param_str , level = "INFO" , item_id = self .__item_id )
159166
160167 def __exit__ (self , exc_type : type [BaseException ], exc_val , exc_tb ) -> None :
161168 """Exit the runtime context related to this object."""
@@ -169,7 +176,7 @@ def __exit__(self, exc_type: type[BaseException], exc_val, exc_tb) -> None:
169176 step_status = self .status
170177 if any ((exc_type , exc_val , exc_tb )):
171178 step_status = "FAILED"
172- rp_client .step_reporter .finish_nested_step (self .__item_id , timestamp ( ), step_status )
179+ rp_client .step_reporter .finish_nested_step (self .__item_id , datetime . now ( tz = timezone . utc ), step_status )
173180
174181 def __call__ (self , * args , ** kwargs ):
175182 """Wrap and call a function reference.
0 commit comments