diff --git a/tests/scripts/test_frame_synchronizer.py b/tests/scripts/test_frame_synchronizer.py index 384a33b1e..87c784cf7 100644 --- a/tests/scripts/test_frame_synchronizer.py +++ b/tests/scripts/test_frame_synchronizer.py @@ -96,7 +96,7 @@ def testZmqHeadetTypeCount(name, num_mods, num_frames, fp): msg = f"Expected {expected_count} '{htype}' entries, found {htype_counts[htype]}" raise RuntimeException(msg) except Exception as e: - raise RuntimeException(f'Failed to get zmq header count type. Error:{e}') + raise RuntimeException(f'Failed to get zmq header count type. Error:{str(e)}') from e Log(LogLevel.INFOGREEN, f"Zmq Header type count test passed for {name}") Log(LogLevel.INFOGREEN, f"Zmq Header type count test passed for {name}", fp) @@ -117,7 +117,7 @@ def startTestsForAll(args, fp): testZmqHeadetTypeCount(server, args.num_mods, args.num_frames, fp) Log(LogLevel.INFO, '\n') except Exception as e: - raise RuntimeException(f'Synchronizer Tests failed') + raise RuntimeException(f'Synchronizer Tests failed') from e Log(LogLevel.INFOGREEN, 'Passed all synchronizer tests for all detectors \n' + str(args.servers)) diff --git a/tests/scripts/test_simulators.py b/tests/scripts/test_simulators.py index fc0a54a34..d6f4371d9 100644 --- a/tests/scripts/test_simulators.py +++ b/tests/scripts/test_simulators.py @@ -65,7 +65,7 @@ def startCmdTestsForAll(args, fp): loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, fp=fp, num_mods=num_mods) runProcessWithLogFile('Cmd Tests for ' + server, cmd, fp, fname) except Exception as e: - raise RuntimeException(f'Cmd Tests failed for {server}.') + raise RuntimeException(f'Cmd Tests failed for {server}.') from e Log(LogLevel.INFOGREEN, 'Passed all tests for all detectors \n' + str(args.servers)) diff --git a/tests/scripts/utils_for_test.py b/tests/scripts/utils_for_test.py index 138ed4076..5f209899a 100644 --- a/tests/scripts/utils_for_test.py +++ b/tests/scripts/utils_for_test.py @@ -71,7 +71,7 @@ def killProcess(name, fp): if p.returncode != 0 and bool(checkIfProcessRunning(name)): raise RuntimeException(f"Could not kill {name} with pid {pid}") except Exception as e: - raise RuntimeException(f"Failed to kill process {name} pid:{pid}. Exception occured: [code:{e}, msg:{e.stderr}]") + raise RuntimeException(f"Failed to kill process {name} pid:{pid}. Error: {str(e)}]") from e #else: # Log(LogLevel.INFO, 'process not running : ' + name) @@ -101,7 +101,7 @@ def startProcessInBackground(cmd, fp): try: p = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, restore_signals=False) except Exception as e: - raise RuntimeException(f'Failed to start {cmd}:{e}') + raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name): @@ -111,7 +111,7 @@ def startProcessInBackgroundWithLogFile(cmd, fp, log_file_name): with open(log_file_name, 'w') as log_fp: subprocess.Popen(cmd, stdout=log_fp, stderr=log_fp, text=True) except Exception as e: - raise RuntimeException(f'Failed to start {cmd}:{e}') + raise RuntimeException(f'Failed to start {cmd}:{str(e)}') from e def runProcessWithLogFile(name, cmd, fp, log_file_name): @@ -124,8 +124,8 @@ def runProcessWithLogFile(name, cmd, fp, log_file_name): except subprocess.CalledProcessError as e: pass except Exception as e: - Log(LogLevel.ERROR, f'Failed to run {name}:{e}', fp) - raise RuntimeException(f'Failed to run {name}:{e}') + Log(LogLevel.ERROR, f'Failed to run {name}:{str(e)}', fp) + raise RuntimeException(f'Failed to run {name}:{str(e)}') with open (log_file_name, 'r') as f: for line in f: @@ -156,7 +156,7 @@ def connectToVirtualServers(name, num_mods): try: d = Detector() except Exception as e: - raise RuntimeException(f'Could not create Detector object for {name}. Error: {str(e)}') + raise RuntimeException(f'Could not create Detector object for {name}. Error: {str(e)}') from e counts_sec = 5 while (counts_sec != 0): @@ -205,7 +205,7 @@ def loadConfig(name, rx_hostname, settingsdir, fp, num_mods = 1, num_frames = 1) d.frames = num_frames except Exception as e: - raise RuntimeException(f'Could not load config for {name}. Error: {str(e)}') + raise RuntimeException(f'Could not load config for {name}. Error: {str(e)}') from e def ParseArguments(description, default_num_mods=1):