Skip to content

Commit

Permalink
Add tests for getting the data directory on different platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
nightlark committed Dec 11, 2024
1 parent 7ac43fc commit 9f962a1
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/config/test_configmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ def test_unix_config_path():
config_manager.delete_instance("testapp")


@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() # pylint: disable=protected-access
expected_data_dir = Path(os.getenv("LOCALAPPDATA", str(Path("~\\AppData\\Local").expanduser())))
assert expected_data_dir in data_dir.parents
# delete instance so other tests don't accidentally use it
config_manager.delete_instance("testapp")


@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() # 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
# delete instance so other tests don't accidentally use it
config_manager.delete_instance("testapp")


def test_preserve_comments(config_manager):
# Create a config file with some value and add in a comment line
config_manager.set("Settings", "theme", "dark")
Expand Down

0 comments on commit 9f962a1

Please sign in to comment.