From 33f9adbc630dd34d1f0ebee85c65a18944f1fcef Mon Sep 17 00:00:00 2001 From: George Dang <53052793+gtdang@users.noreply.github.com> Date: Wed, 8 May 2024 17:15:32 -0400 Subject: [PATCH] tests: Updated to use Pathlib for file pathing --- hnn_core/tests/test_gui.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hnn_core/tests/test_gui.py b/hnn_core/tests/test_gui.py index 31bef7aa1..d202fdf19 100644 --- a/hnn_core/tests/test_gui.py +++ b/hnn_core/tests/test_gui.py @@ -8,6 +8,7 @@ import traitlets import os +from pathlib import Path from hnn_core import Dipole, Network, Params from hnn_core.gui import HNNGUI from hnn_core.gui._viz_manager import (_idx2figname, _no_overlay_plot_types, @@ -21,6 +22,8 @@ from ipywidgets import Tab, Text, link matplotlib.use('agg') +hnn_core_root = Path(__file__).parents[1] +assets_path = Path(hnn_core_root, 'tests', 'assets') @pytest.fixture @@ -586,15 +589,16 @@ def test_gui_upload_csv_simulation(setup_gui): assert len(gui.viz_manager.data['figs']) == 0 assert len(gui.data['simulation_data']) == 0 - # Relative path to the file - file_relative_path = "./hnn_core/tests/assets/test_default.csv" - absolute_path = os.path.abspath(file_relative_path) + # Formulate path to the file + file_path = assets_path / 'test_default.csv' + absolute_path = str(file_path.resolve()) if os.name == 'nt': # Windows # Convert backslashes to forward slashes and # ensure we have three slashes after 'file:' file_url = 'file:///' + absolute_path.replace('\\', '/') else: # UNIX-like systems file_url = 'file://' + absolute_path + _ = gui._simulate_upload_data(file_url) # we are loading only 1 trial,