Skip to content

Commit

Permalink
Add utils to tests - working on workflow paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jpcurbelo committed Aug 31, 2024
1 parent faec1de commit 57e7b0b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
12 changes: 10 additions & 2 deletions TESTS/test_data_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
22 changes: 22 additions & 0 deletions TESTS/utils.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 57e7b0b

Please sign in to comment.