diff --git a/surfactant/configmanager.py b/surfactant/configmanager.py index 7ee69b3a..0c62ab22 100644 --- a/surfactant/configmanager.py +++ b/surfactant/configmanager.py @@ -74,8 +74,8 @@ def _get_config_file_path(self) -> Path: config_dir = Path(os.getenv("APPDATA", str(Path("~\\AppData\\Roaming")))) else: config_dir = Path(os.getenv("XDG_CONFIG_HOME", str(Path("~/.config")))) - config_dir = config_dir / self.app_name - return config_dir / "config.toml" + config_dir = config_dir / self.app_name / "config.toml" + return config_dir.expanduser() def _load_config(self) -> None: """Loads the configuration from the configuration file.""" @@ -153,4 +153,4 @@ def get_data_dir_path(self) -> Path: else: data_dir = Path(os.getenv("XDG_DATA_HOME", str(Path("~/.local/share")))) data_dir = data_dir / self.app_name - return data_dir + return data_dir.expanduser() diff --git a/tests/config/test_configmanager.py b/tests/config/test_configmanager.py index a5cb3d4a..7cec20b2 100644 --- a/tests/config/test_configmanager.py +++ b/tests/config/test_configmanager.py @@ -57,7 +57,7 @@ def test_config_file_creation(config_manager): @pytest.mark.skipif(platform.system() != "Windows", reason="Test specific to Windows platform") def test_windows_config_path(): config_manager = ConfigManager(app_name="testapp") - config_path = config_manager._get_config_file_path().expanduser() # pylint: disable=protected-access + config_path = config_manager._get_config_file_path() # pylint: disable=protected-access expected_config_dir = Path(os.getenv("APPDATA", str(Path("~\\AppData\\Roaming").expanduser()))) assert expected_config_dir in config_path.parents assert config_path.parts[-2:] == ("testapp", "config.toml") @@ -68,7 +68,7 @@ def test_windows_config_path(): @pytest.mark.skipif(platform.system() == "Windows", reason="Test specific to Unix-like platforms") def test_unix_config_path(): config_manager = ConfigManager(app_name="testapp") - config_path = config_manager._get_config_file_path().expanduser() # pylint: disable=protected-access + config_path = config_manager._get_config_file_path() # pylint: disable=protected-access expected_config_dir = Path(os.getenv("XDG_CONFIG_HOME", str(Path("~/.config").expanduser()))) assert expected_config_dir in config_path.parents assert config_path.parts[-2:] == ("testapp", "config.toml") @@ -79,7 +79,7 @@ def test_unix_config_path(): @pytest.mark.skipif(platform.system() != "Windows", reason="Test specific to Windows platform") def test_windows_data_dir_path(): config_manager = ConfigManager(app_name="testapp") - data_dir = config_manager.get_data_dir_path().expanduser() # pylint: disable=protected-access + data_dir = config_manager.get_data_dir_path() # pylint: disable=protected-access expected_data_dir = Path(os.getenv("LOCALAPPDATA", str(Path("~\\AppData\\Local").expanduser()))) assert expected_data_dir in data_dir.parents assert data_dir.name == "testapp" @@ -90,7 +90,7 @@ def test_windows_data_dir_path(): @pytest.mark.skipif(platform.system() == "Windows", reason="Test specific to Unix-like platforms") def test_unix_data_dir_path(): config_manager = ConfigManager(app_name="testapp") - data_dir = config_manager.get_data_dir_path().expanduser() # pylint: disable=protected-access + data_dir = config_manager.get_data_dir_path() # pylint: disable=protected-access expected_data_dir = Path(os.getenv("XDG_DATA_HOME", str(Path("~/.local/share").expanduser()))) assert expected_data_dir in data_dir.parents assert data_dir.name == "testapp"