Skip to content

Commit

Permalink
another test iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuchan-reef committed Nov 23, 2023
1 parent 83d0558 commit 9c2fc74
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions b2sdk/account_info/sqlite_account_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ def __init__(self, file_name=None, last_upgrade_to_run=None, profile: str | None
)

@classmethod
def get_xdg_config_path(cls) -> str | None:
def get_xdg_config_path(cls, home_dir: str = '~') -> str | None:
"""
Return XDG config path if the OS is XDG-compatible (Linux, BSD), None otherwise.
If $XDG_CONFIG_HOME is empty but the OS is XDG compliant, fallback to ~/.config as expected by XDG standard.
"""
xdg_config_home = os.getenv(XDG_CONFIG_HOME_ENV_VAR)
if xdg_config_home or sys.platform.startswith(('linux', 'freebsd', 'openbsd', 'netbsd')):
config_path = xdg_config_home or '~/.config'
config_path = xdg_config_home or os.path.join(home_dir, '.config')
return os.path.expanduser(config_path)
return None

Expand Down
2 changes: 1 addition & 1 deletion test/unit/account_info/test_account_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def _make_sqlite_account_info(self, env=None, last_upgrade_to_run=None):
)

def test_uses_default(self):
xdg_config_path = SqliteAccountInfo.get_xdg_config_path()
xdg_config_path = SqliteAccountInfo.get_xdg_config_path(self.test_home)

account_info = self._make_sqlite_account_info(
env={
Expand Down

0 comments on commit 9c2fc74

Please sign in to comment.