From 1dcbc23047115ef1e08ca102e369ba94f0a57a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schm=C3=B6lder?= Date: Sat, 10 May 2025 16:35:48 +0200 Subject: [PATCH] Expand user when setting install path --- cadet/cadet.py | 2 +- tests/test_install_path_settings.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cadet/cadet.py b/cadet/cadet.py index a8e3a22..5a63636 100644 --- a/cadet/cadet.py +++ b/cadet/cadet.py @@ -52,7 +52,7 @@ def resolve_cadet_paths( if install_path is None: return None, None, None, None - install_path = Path(install_path) + install_path = Path(install_path).expanduser() if install_path.is_file(): cadet_root = install_path.parent.parent diff --git a/tests/test_install_path_settings.py b/tests/test_install_path_settings.py index e707ad6..9606218 100644 --- a/tests/test_install_path_settings.py +++ b/tests/test_install_path_settings.py @@ -11,6 +11,7 @@ # Full path to cadet.dll or cadet.so, that is different from the system/conda cadet full_path_dll = Path("path/to/cadet") +home_path_dll = Path("path/to/cadet") install_path_conda = Cadet.autodetect_cadet() @@ -22,6 +23,7 @@ def test_autodetection(): assert sim.cadet_cli_path.parent.parent == install_path_conda assert sim.cadet_runner.cadet_path.suffix not in [".dll", ".so"] + @pytest.mark.local def test_install_path(): if full_path_dll == Path("path/to/cadet"): @@ -30,12 +32,21 @@ def test_install_path(): assert sim.cadet_dll_path == full_path_dll assert sim.cadet_runner.cadet_path.suffix in [".dll", ".so"] + # Set root directory of CADET installation sim = Cadet() sim.install_path = full_path_dll.parent.parent sim.use_dll = True assert sim.cadet_dll_path == full_path_dll assert sim.cadet_runner.cadet_path.suffix in [".dll", ".so"] + # Set root directory of CADET installation (with user home (`~`)) + sim = Cadet() + sim.install_path = home_path_dll.parent.parent + sim.use_dll = True + assert sim.cadet_dll_path == full_path_dll + assert sim.cadet_runner.cadet_path.suffix in [".dll", ".so"] + + # Set cli/dll path (deprecated) sim = Cadet() with pytest.deprecated_call(): sim.cadet_path = full_path_dll.parent.parent