From 57e7b0b754ecc4b4c73b1c20a9bd422bd3915533 Mon Sep 17 00:00:00 2001 From: jpcurbelo Date: Sat, 31 Aug 2024 07:27:19 -0600 Subject: [PATCH] Add utils to tests - working on workflow paths --- TESTS/test_data_fitting.py | 12 ++++++++++-- TESTS/utils.py | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 TESTS/utils.py diff --git a/TESTS/test_data_fitting.py b/TESTS/test_data_fitting.py index c405512c..2f4c82a6 100644 --- a/TESTS/test_data_fitting.py +++ b/TESTS/test_data_fitting.py @@ -3,6 +3,8 @@ import unittest import sys +from utils import get_test_data_path + # Get the parent directory of the current script's directory parent_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) # Add the parent directory to the system path @@ -29,8 +31,14 @@ def test_ChangeSampleParams_element(self): my_path = os.getcwd() + '/test_data/' + filename script_name = '/test_data/test_script.txt' else: - my_path = os.getcwd() + '/test_data/' + filename - script_name = '/test_data/test_script.txt' + # my_path = os.getcwd() + '/test_data/' + filename + # script_name = '/test_data/test_script.txt' + my_path = get_test_data_path(filename) + script_name = get_test_data_path('test_script.txt') + + print('\nmy_path', my_path) + print('script_name', script_name) + aux = input('Press enter to continue') sample = ds.ReadSampleHDF5(my_path) diff --git a/TESTS/utils.py b/TESTS/utils.py new file mode 100644 index 00000000..6969cfa3 --- /dev/null +++ b/TESTS/utils.py @@ -0,0 +1,22 @@ + +# This file contains utility functions for the tests. +import os + +def get_test_data_path(filename): + """ + Returns the full path to a test data file, adjusting for different environments. + """ + base_dir = os.path.dirname(os.path.abspath(__file__)) + # Adjust the base directory if needed + test_data_dir = os.path.join(base_dir, 'test_data') + + return os.path.join(test_data_dir, filename) + + + + + + +if __name__ == "__main__": + + pass \ No newline at end of file