Skip to content

Commit

Permalink
Remove redundant expanduser() call in config manager tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nightlark committed Dec 17, 2024
1 parent 151cdfa commit 98371a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions surfactant/configmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
8 changes: 4 additions & 4 deletions tests/config/test_configmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit 98371a8

Please sign in to comment.