Skip to content

Commit 932b9ed

Browse files
committed
Making use of current_tc_no instead of sharing it to global
1 parent 325637e commit 932b9ed

File tree

2 files changed

+13
-20
lines changed

2 files changed

+13
-20
lines changed

Framework/MainDriverApi.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,6 @@ def run_test_case(
950950
browserDriver=None,
951951
):
952952
try:
953-
prev_zeuz_tc_logs = shared.Get_Shared_Variables("zeuz_tc_logs")
954-
prev_zeuz_tc_logs['current_test_case_id'] = TestCaseID
955-
shared.Set_Shared_Variables("zeuz_tc_logs", prev_zeuz_tc_logs, pretty=False, print_variable=False)
956953
TestCaseStartTime = time.time()
957954
test_case = str(TestCaseID).replace("#", "no")
958955
CommonUtil.current_tc_no = test_case
@@ -972,6 +969,7 @@ def run_test_case(
972969
shared.Set_Shared_Variables("zeuz_prettify_limit", 500)
973970
CommonUtil.prettify_limit = 500
974971

972+
shared.Set_Shared_Variables("zeuz_tc_logs", {"errors": []}, pretty=False, print_variable=False)
975973
shared.Set_Shared_Variables("zeuz_attachments_dir", (Path(temp_ini_file).parent/"attachments").__str__())
976974
if not shared.Test_Shared_Variables("element_wait"):
977975
shared.Set_Shared_Variables("element_wait", 10)
@@ -1805,8 +1803,6 @@ def download_or_copy(attachment):
18051803
# main function
18061804
def main(device_dict, all_run_id_info):
18071805
try:
1808-
# Set TC logs
1809-
shared.Set_Shared_Variables("zeuz_tc_logs", {"errors": []}, print_variable=False, pretty=False)
18101806
# get module info
18111807
sModuleInfo = inspect.currentframe().f_code.co_name + " : " + MODULE_NAME
18121808

@@ -1949,7 +1945,6 @@ def main(device_dict, all_run_id_info):
19491945

19501946
shared.Set_Shared_Variables("run_id", run_id)
19511947
shared.Set_Shared_Variables("node_id", CommonUtil.MachineInfo().getLocalUser())
1952-
shared.Set_Shared_Variables("zeuz_tc_logs", {"errors": []}, print_variable=False, pretty=False)
19531948

19541949
send_log_file_only_for_fail = ConfigModule.get_config_value("RunDefinition", "upload_log_file_only_for_fail")
19551950
send_log_file_only_for_fail = False if send_log_file_only_for_fail.lower() == "false" else True

Framework/Utilities/CommonUtil.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -707,20 +707,18 @@ def ExecLog(
707707
try:
708708
from Framework.Built_In_Automation.Shared_Resources import BuiltInFunctionSharedResources as shared
709709
zeuz_tc_logs = shared.Get_Shared_Variables("zeuz_tc_logs")
710-
if not zeuz_tc_logs or not isinstance(zeuz_tc_logs, dict):
711-
zeuz_tc_logs = {"errors": []}
712-
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
713-
test_case_id = zeuz_tc_logs.get("current_test_case_id", 'unknown')
714-
error_entry = {
715-
"step": int(current_step_no),
716-
"action": int(current_action_no),
717-
"module": sModuleInfo,
718-
"message": sDetails,
719-
"test_case_id": test_case_id,
720-
"timestamp": now
721-
}
722-
zeuz_tc_logs["errors"].append(error_entry)
723-
shared.Set_Shared_Variables("zeuz_tc_logs", zeuz_tc_logs, print_variable=False, pretty=False)
710+
if zeuz_tc_logs and isinstance(zeuz_tc_logs, dict):
711+
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
712+
error_entry = {
713+
"step": int(current_step_no),
714+
"action": int(current_action_no),
715+
"module": sModuleInfo,
716+
"message": sDetails,
717+
"test_case_id": current_tc_no,
718+
"timestamp": now
719+
}
720+
zeuz_tc_logs["errors"].append(error_entry)
721+
shared.Set_Shared_Variables("zeuz_tc_logs", zeuz_tc_logs, print_variable=False, pretty=False)
724722
except:
725723
pass
726724

0 commit comments

Comments
 (0)