From da797ddd718dfd5f1f892180d35902c513238111 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 1 May 2026 10:25:06 +0100 Subject: [PATCH 01/14] edit file saving increase threshold and add warning to counter --- packs/proc/processing_utils.py | 48 +++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/packs/proc/processing_utils.py b/packs/proc/processing_utils.py index e027f15..34fbfc9 100644 --- a/packs/proc/processing_utils.py +++ b/packs/proc/processing_utils.py @@ -341,38 +341,56 @@ def save_data(event_information : np.ndarray, -def check_save_path(save_path : str, - overwrite : bool): +def check_save_path(save_path : str, + overwrite : bool, + warn_threshold : Optional[int] = 100, + max_iterations : Optional[int] = 1000): ''' Checks that the save_path exists. Checks if it is valid/doesn't already exist - and if it does, other `overwrite` it or create an additional file with a number added. + and if it does, either overwrite it or create an additional file with a number added. Parameters ---------- - - save_path (str) : Path to saved file - overwrite (bool) : Boolean for overwriting pre-existing files + save_path (str) : Path to saved file + overwrite (bool) : Boolean for overwriting pre-existing files + warn_threshold (int) : Number of iterations before a warning is issued (default 100) + max_iterations (int) : Maximum number of iterations before raising an error (default 1000) Returns ------- save_path (str) : Valid path to saved file, either unmodified or altered to add '_N' - where N is number of loops it had to do before finding a valid N + where N is the first available number + Raises + ------ + FileNotFoundError : If the directory of save_path does not exist + RuntimeError : If max_iterations is exceeded ''' if not os.path.exists(os.path.dirname(save_path)): raise FileNotFoundError(2, 'Save path not found', os.path.dirname(save_path)) + if overwrite or not os.path.exists(save_path): + return save_path + name, ext = os.path.splitext(save_path) - counter = 1 - if overwrite == False: - while os.path.exists(save_path): - save_path = name + str(counter) + ext - counter += 1 - if counter > 100: - raise RuntimeError("Writing to file went over 100 loops to find a unique name. Sort out your files!") + for counter in range(1, max_iterations + 1): + candidate = f"{name}_{counter}{ext}" + + if counter == warn_threshold: + warnings.warn( + f"Over {warn_threshold} files with the name '{os.path.basename(name)}' exist. " + f"Consider tidying up your files.", + UserWarning + ) + + if not os.path.exists(candidate): + return candidate - return save_path + raise RuntimeError( + f"Could not find a unique filename after {max_iterations} attempts for '{save_path}'. " + f"Consider tidying up your files." + ) ## Interactive prompt? datetime naming? def process_event_lazy_WD1(file_object : BinaryIO): From 07a674da1aea5d8c636377c2d324137db179ea68 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 1 May 2026 14:16:10 +0100 Subject: [PATCH 02/14] change `check_save_path()` Use timestamp naming in file creation when overwrite is false. Have user input to double check overwriting. --- packs/proc/processing_utils.py | 63 ++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/packs/proc/processing_utils.py b/packs/proc/processing_utils.py index 34fbfc9..bd32352 100644 --- a/packs/proc/processing_utils.py +++ b/packs/proc/processing_utils.py @@ -12,6 +12,7 @@ from typing import BinaryIO from typing import Generic from typing import Optional +from datetime import datetime # imports start from MULE/ from packs.core.core_utils import flatten @@ -341,56 +342,58 @@ def save_data(event_information : np.ndarray, -def check_save_path(save_path : str, - overwrite : bool, - warn_threshold : Optional[int] = 100, - max_iterations : Optional[int] = 1000): +def check_save_path(save_path: str, overwrite: bool): ''' - Checks that the save_path exists. Checks if it is valid/doesn't already exist - and if it does, either overwrite it or create an additional file with a number added. + Checks that the save_path directory exists, then either returns the path unmodified + (if overwrite is True) or generates a unique save path by inserting a datetime stamp + (YYYYMMDD_HHMMSS) before the file extension. If a file with that datetime name already + exists, a counter suffix is appended. + + If overwrite is True and the file already exists, the user is prompted to confirm. + If the user declines, the function falls back to datetime-stamped naming. Parameters ---------- - save_path (str) : Path to saved file - overwrite (bool) : Boolean for overwriting pre-existing files - warn_threshold (int) : Number of iterations before a warning is issued (default 100) - max_iterations (int) : Maximum number of iterations before raising an error (default 1000) + save_path (str) : Path to saved file + overwrite (bool) : If True, returns save_path unmodified after confirmation. + If False, appends '_YYYYMMDD_HHMMSS' to the stem, plus '_N' + if needed. Returns ------- - save_path (str) : Valid path to saved file, either unmodified or altered to add '_N' - where N is the first available number + save_path (str) : Valid path to saved file, either unmodified or with datetime + stamp and optional counter appended Raises ------ FileNotFoundError : If the directory of save_path does not exist - RuntimeError : If max_iterations is exceeded ''' if not os.path.exists(os.path.dirname(save_path)): raise FileNotFoundError(2, 'Save path not found', os.path.dirname(save_path)) - if overwrite or not os.path.exists(save_path): - return save_path + if overwrite: + if os.path.exists(save_path): + response = input(f"'{save_path}' already exists. Overwrite? (y/n): ").strip().lower() + if response != 'y': + overwrite = False + else: + return save_path - name, ext = os.path.splitext(save_path) + if not overwrite: + name, ext = os.path.splitext(save_path) + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + dated_path = f"{name}_{timestamp}{ext}" - for counter in range(1, max_iterations + 1): - candidate = f"{name}_{counter}{ext}" + if not os.path.exists(dated_path): + return dated_path - if counter == warn_threshold: - warnings.warn( - f"Over {warn_threshold} files with the name '{os.path.basename(name)}' exist. " - f"Consider tidying up your files.", - UserWarning - ) + counter = 1 + while os.path.exists(f"{name}_{timestamp}_{counter}{ext}"): + counter += 1 - if not os.path.exists(candidate): - return candidate + return f"{name}_{timestamp}_{counter}{ext}" - raise RuntimeError( - f"Could not find a unique filename after {max_iterations} attempts for '{save_path}'. " - f"Consider tidying up your files." - ) ## Interactive prompt? datetime naming? + return save_path def process_event_lazy_WD1(file_object : BinaryIO): From c0455ff478d3b62c92b553d14a7b353e1099364c Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 8 May 2026 15:57:33 +0100 Subject: [PATCH 03/14] remove overwrite prompt --- packs/proc/processing_utils.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packs/proc/processing_utils.py b/packs/proc/processing_utils.py index bd32352..1174707 100644 --- a/packs/proc/processing_utils.py +++ b/packs/proc/processing_utils.py @@ -349,9 +349,6 @@ def check_save_path(save_path: str, overwrite: bool): (YYYYMMDD_HHMMSS) before the file extension. If a file with that datetime name already exists, a counter suffix is appended. - If overwrite is True and the file already exists, the user is prompted to confirm. - If the user declines, the function falls back to datetime-stamped naming. - Parameters ---------- save_path (str) : Path to saved file @@ -372,12 +369,7 @@ def check_save_path(save_path: str, overwrite: bool): raise FileNotFoundError(2, 'Save path not found', os.path.dirname(save_path)) if overwrite: - if os.path.exists(save_path): - response = input(f"'{save_path}' already exists. Overwrite? (y/n): ").strip().lower() - if response != 'y': - overwrite = False - else: - return save_path + return save_path if not overwrite: name, ext = os.path.splitext(save_path) From 34333c0e2e181e5586555d208f5daf0527630534 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 8 May 2026 16:15:13 +0100 Subject: [PATCH 04/14] edit test to include all config params overwrite specifically --- packs/tests/proc_test.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packs/tests/proc_test.py b/packs/tests/proc_test.py index 00f6828..fb6dcbc 100644 --- a/packs/tests/proc_test.py +++ b/packs/tests/proc_test.py @@ -55,13 +55,16 @@ def test_changing_config_order(config, inpt, output, comparison, MULE_dir, data_ # Rebuild the section in new order new_order = ["save_path", "file_path", "wavedump_edition", "process"] + all_keys = list(cnfg["required"].keys()) + extra_keys = [k for k in all_keys if k not in new_order] + reordered = configparser.ConfigParser() reordered.add_section("required") - for key in new_order: + for key in new_order + extra_keys: reordered.set("required", key, cnfg.get("required", key)) - reordered.set('required', 'file_path', "'" + file_path + "'") # need to add comments around for config reasons + reordered.set('required', 'file_path', f"'{file_path}'") reordered.set('required', 'save_path', f"'{save_path}'") # Write back From 20af3ba80eb073585d95a0a0a2228450648aaa90 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 8 May 2026 16:15:51 +0100 Subject: [PATCH 05/14] edit test to expect datetime --- packs/tests/processing_test.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packs/tests/processing_test.py b/packs/tests/processing_test.py index b5d45aa..ff4c417 100644 --- a/packs/tests/processing_test.py +++ b/packs/tests/processing_test.py @@ -1,5 +1,6 @@ import os import sys +import re import numpy as np import pandas as pd @@ -153,13 +154,13 @@ def test_save_path_exists(): def test_ensure_new_path_created(data_dir): + data_path = data_dir + 'three_channels_WD2.h5' + found_path = check_save_path(data_path, overwrite=False) - data_path = data_dir + 'three_channels_WD2.h5' - new_data_path = data_dir + 'three_channels_WD21.h5' - - found_path = check_save_path(data_path, overwrite = False) - - assert found_path == new_data_path + assert found_path != data_path + assert found_path.endswith('.h5') + assert re.search(r'_\d{8}_\d{6}', found_path), "Expected datetime stamp in filename" + assert not os.path.exists(found_path), "Path should not already exist" def test_runtime_error_when_too_many_save_files(data_dir): From 115b3f9ce01073abc0a6967dc4dcf9c84dc21b00 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 8 May 2026 16:19:26 +0100 Subject: [PATCH 06/14] add safety net to saving --- packs/proc/processing_utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packs/proc/processing_utils.py b/packs/proc/processing_utils.py index 1174707..5f84334 100644 --- a/packs/proc/processing_utils.py +++ b/packs/proc/processing_utils.py @@ -371,6 +371,8 @@ def check_save_path(save_path: str, overwrite: bool): if overwrite: return save_path + MAX_ATTEMPTS = 100 + if not overwrite: name, ext = os.path.splitext(save_path) timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") @@ -381,6 +383,8 @@ def check_save_path(save_path: str, overwrite: bool): counter = 1 while os.path.exists(f"{name}_{timestamp}_{counter}{ext}"): + if counter >= MAX_ATTEMPTS: + raise RuntimeError(f"Too many save files with the same timestamp: {dated_path}") counter += 1 return f"{name}_{timestamp}_{counter}{ext}" From 579eb97fa8c1ce52863d826e1c90672187fefd30 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 8 May 2026 16:21:50 +0100 Subject: [PATCH 07/14] update runtime error test --- packs/tests/processing_test.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packs/tests/processing_test.py b/packs/tests/processing_test.py index ff4c417..3752789 100644 --- a/packs/tests/processing_test.py +++ b/packs/tests/processing_test.py @@ -1,3 +1,4 @@ +import datetime import os import sys import re @@ -163,17 +164,16 @@ def test_ensure_new_path_created(data_dir): assert not os.path.exists(found_path), "Path should not already exist" -def test_runtime_error_when_too_many_save_files(data_dir): +def test_runtime_error_when_too_many_save_files(tmp_path): + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") - relevant_dir = data_dir + 'repetitive_data/' - # generate 101 empty files - with open(relevant_dir + f'test_.txt', 'w'): - pass + # create the base file and 100 counter variants with the same timestamp + (tmp_path / f'test_{timestamp}.txt').touch() for i in range(1, 101): - with open(relevant_dir + f'test_{i}.txt', 'w'): - pass + (tmp_path / f'test_{timestamp}_{i}.txt').touch() + with raises(RuntimeError): - check_save_path(relevant_dir + 'test_.txt', overwrite=False) + check_save_path(str(tmp_path / 'test.txt'), overwrite=False) @mark.parametrize("config, inpt, output, comparison", [("process_WD2_1channel.conf", "one_channel_WD2.bin", "one_channel_tmp.h5", "one_channel_WD2.h5"), ("process_WD2_3channel.conf", "three_channels_WD2.bin", "three_channels_tmp.h5", "three_channels_WD2.h5")]) From b874b9efb70aee6dc8be030a616c8ece230f8b78 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 8 May 2026 16:25:17 +0100 Subject: [PATCH 08/14] remove redundant file --- packs/tests/data/repetitive_data/force_folder_file.bs | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 packs/tests/data/repetitive_data/force_folder_file.bs diff --git a/packs/tests/data/repetitive_data/force_folder_file.bs b/packs/tests/data/repetitive_data/force_folder_file.bs deleted file mode 100644 index e69de29..0000000 From a0451ba661365e7523b15a9fb09fed7436023fdf Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 8 May 2026 16:32:04 +0100 Subject: [PATCH 09/14] include optional config args in test --- packs/tests/proc_test.py | 41 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/packs/tests/proc_test.py b/packs/tests/proc_test.py index fb6dcbc..f139196 100644 --- a/packs/tests/proc_test.py +++ b/packs/tests/proc_test.py @@ -58,26 +58,21 @@ def test_changing_config_order(config, inpt, output, comparison, MULE_dir, data_ all_keys = list(cnfg["required"].keys()) extra_keys = [k for k in all_keys if k not in new_order] - reordered = configparser.ConfigParser() - reordered.add_section("required") - - for key in new_order + extra_keys: - reordered.set("required", key, cnfg.get("required", key)) - - reordered.set('required', 'file_path', f"'{file_path}'") - reordered.set('required', 'save_path', f"'{save_path}'") - - # Write back - with open(config_path, "w") as f: - reordered.write(f) - - # run processing pack decode - run_pack = [sys.executable, MULE_dir + "/bin/mule", "proc", config_path] - subprocess.run(run_pack) - # check that the resulting dataframe is as expected - assert load_evt_info(save_path).equals(load_evt_info(comparison_path)) - assert load_rwf_info(save_path, samples).equals(load_rwf_info(comparison_path, samples)) - finally: - # rewrite config file to original state - with open(config_path, "w") as f: - f.write(original_content) + reordered = configparser.ConfigParser() + reordered.add_section("required") + + for key in new_order + extra_keys: + reordered.set("required", key, cnfg.get("required", key)) + + reordered.set('required', 'file_path', f"'{file_path}'") + reordered.set('required', 'save_path', f"'{save_path}'") + + # copy over all other sections unchanged + for section in cnfg.sections(): + if section != "required": + reordered.add_section(section) + for key, value in cnfg.items(section): + reordered.set(section, key, value) + + with open(config_path, "w") as f: + reordered.write(f) From 6c507bee443b1d51fdfc457ae57aa5a8e75cdf14 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 8 May 2026 16:34:53 +0100 Subject: [PATCH 10/14] import datetime properly --- packs/tests/processing_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packs/tests/processing_test.py b/packs/tests/processing_test.py index 3752789..5abff25 100644 --- a/packs/tests/processing_test.py +++ b/packs/tests/processing_test.py @@ -1,4 +1,4 @@ -import datetime +from datetime import datetime import os import sys import re From 12de176d9b45a22314d077649794694a8fdd7069 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Fri, 8 May 2026 16:39:32 +0100 Subject: [PATCH 11/14] fix try statement --- packs/tests/proc_test.py | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/packs/tests/proc_test.py b/packs/tests/proc_test.py index f139196..5cf7a5d 100644 --- a/packs/tests/proc_test.py +++ b/packs/tests/proc_test.py @@ -53,26 +53,34 @@ def test_changing_config_order(config, inpt, output, comparison, MULE_dir, data_ cnfg = configparser.ConfigParser() cnfg.read(config_path) - # Rebuild the section in new order new_order = ["save_path", "file_path", "wavedump_edition", "process"] all_keys = list(cnfg["required"].keys()) extra_keys = [k for k in all_keys if k not in new_order] - reordered = configparser.ConfigParser() - reordered.add_section("required") + reordered = configparser.ConfigParser() + reordered.add_section("required") - for key in new_order + extra_keys: - reordered.set("required", key, cnfg.get("required", key)) + for key in new_order + extra_keys: + reordered.set("required", key, cnfg.get("required", key)) - reordered.set('required', 'file_path', f"'{file_path}'") - reordered.set('required', 'save_path', f"'{save_path}'") + reordered.set('required', 'file_path', f"'{file_path}'") + reordered.set('required', 'save_path', f"'{save_path}'") - # copy over all other sections unchanged - for section in cnfg.sections(): - if section != "required": - reordered.add_section(section) - for key, value in cnfg.items(section): - reordered.set(section, key, value) + for section in cnfg.sections(): + if section != "required": + reordered.add_section(section) + for key, value in cnfg.items(section): + reordered.set(section, key, value) - with open(config_path, "w") as f: - reordered.write(f) + with open(config_path, "w") as f: + reordered.write(f) + + run_pack = [sys.executable, MULE_dir + "/bin/mule", "proc", config_path] + subprocess.run(run_pack) + + assert load_evt_info(save_path).equals(load_evt_info(comparison_path)) + assert load_rwf_info(save_path, samples).equals(load_rwf_info(comparison_path, samples)) + + finally: + with open(config_path, "w") as f: + f.write(original_content) From 81d4444432e236b951a2310e69eca5164aaed93a Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Mon, 11 May 2026 10:25:07 +0100 Subject: [PATCH 12/14] make max_iterations an optional arg instead of a local variable --- packs/proc/processing_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packs/proc/processing_utils.py b/packs/proc/processing_utils.py index 5f84334..468231e 100644 --- a/packs/proc/processing_utils.py +++ b/packs/proc/processing_utils.py @@ -342,7 +342,9 @@ def save_data(event_information : np.ndarray, -def check_save_path(save_path: str, overwrite: bool): +def check_save_path(save_path: str, + overwrite: bool, + max_iterations : Optional[int] = 100) -> str: ''' Checks that the save_path directory exists, then either returns the path unmodified (if overwrite is True) or generates a unique save path by inserting a datetime stamp @@ -355,6 +357,7 @@ def check_save_path(save_path: str, overwrite: bool): overwrite (bool) : If True, returns save_path unmodified after confirmation. If False, appends '_YYYYMMDD_HHMMSS' to the stem, plus '_N' if needed. + max_iterations (int): Maximum number of iterations to find a unique filename before raising an error Returns ------- @@ -371,7 +374,6 @@ def check_save_path(save_path: str, overwrite: bool): if overwrite: return save_path - MAX_ATTEMPTS = 100 if not overwrite: name, ext = os.path.splitext(save_path) @@ -383,7 +385,7 @@ def check_save_path(save_path: str, overwrite: bool): counter = 1 while os.path.exists(f"{name}_{timestamp}_{counter}{ext}"): - if counter >= MAX_ATTEMPTS: + if counter >= max_iterations: raise RuntimeError(f"Too many save files with the same timestamp: {dated_path}") counter += 1 From 17dcd9a67eac5ee92874b1b4a693cd4d7aa604b7 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Mon, 11 May 2026 10:54:00 +0100 Subject: [PATCH 13/14] fix counter warning test mock fixed datetime for module --- packs/tests/processing_test.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packs/tests/processing_test.py b/packs/tests/processing_test.py index 5abff25..6d3dbdc 100644 --- a/packs/tests/processing_test.py +++ b/packs/tests/processing_test.py @@ -37,6 +37,9 @@ from hypothesis import given from hypothesis.strategies import integers + +from unittest.mock import patch, MagicMock + @given(integers(min_value = 1, max_value = 1000000)) def test_rwf_type_has_correct_shape(samples): x = rwf_type(samples) @@ -165,15 +168,17 @@ def test_ensure_new_path_created(data_dir): def test_runtime_error_when_too_many_save_files(tmp_path): - timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + timestamp = "20240101_120000" + mock_dt = MagicMock() + mock_dt.now.return_value.strftime.return_value = timestamp - # create the base file and 100 counter variants with the same timestamp (tmp_path / f'test_{timestamp}.txt').touch() for i in range(1, 101): (tmp_path / f'test_{timestamp}_{i}.txt').touch() - with raises(RuntimeError): - check_save_path(str(tmp_path / 'test.txt'), overwrite=False) + with patch('packs.proc.processing_utils.datetime', mock_dt): + with raises(RuntimeError): + check_save_path(str(tmp_path / 'test.txt'), overwrite=False) @mark.parametrize("config, inpt, output, comparison", [("process_WD2_1channel.conf", "one_channel_WD2.bin", "one_channel_tmp.h5", "one_channel_WD2.h5"), ("process_WD2_3channel.conf", "three_channels_WD2.bin", "three_channels_tmp.h5", "three_channels_WD2.h5")]) From e0bbdbf6c1bbe59036620cb656a683002e065048 Mon Sep 17 00:00:00 2001 From: Tedsmith100 Date: Mon, 11 May 2026 16:13:52 +0100 Subject: [PATCH 14/14] add comments to test --- packs/tests/proc_test.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packs/tests/proc_test.py b/packs/tests/proc_test.py index 5cf7a5d..581d54a 100644 --- a/packs/tests/proc_test.py +++ b/packs/tests/proc_test.py @@ -35,7 +35,7 @@ def test_changing_config_order(config, inpt, output, comparison, MULE_dir, data_ Test that ensure that changing the order of the config parameters inputted does not affect the code. """ - # ensure path is correct + # Build absolute paths for all files file_path = data_dir + inpt save_path = data_dir + output comparison_path = data_dir + comparison @@ -57,15 +57,18 @@ def test_changing_config_order(config, inpt, output, comparison, MULE_dir, data_ all_keys = list(cnfg["required"].keys()) extra_keys = [k for k in all_keys if k not in new_order] + # create a new config with the same parameters but in a different order reordered = configparser.ConfigParser() reordered.add_section("required") for key in new_order + extra_keys: reordered.set("required", key, cnfg.get("required", key)) - + + # overide the file_path and save_path to test specific paths reordered.set('required', 'file_path', f"'{file_path}'") reordered.set('required', 'save_path', f"'{save_path}'") + # Copy over any other sections without changing their order for section in cnfg.sections(): if section != "required": reordered.add_section(section) @@ -75,12 +78,15 @@ def test_changing_config_order(config, inpt, output, comparison, MULE_dir, data_ with open(config_path, "w") as f: reordered.write(f) + # Run MULE proc with reordered config run_pack = [sys.executable, MULE_dir + "/bin/mule", "proc", config_path] subprocess.run(run_pack) + # check that the output is as expected assert load_evt_info(save_path).equals(load_evt_info(comparison_path)) assert load_rwf_info(save_path, samples).equals(load_rwf_info(comparison_path, samples)) + # restore config to original finally: with open(config_path, "w") as f: f.write(original_content)