Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User path override has no effect #37

Closed
jaraco opened this issue Sep 25, 2024 · 0 comments
Closed

User path override has no effect #37

jaraco opened this issue Sep 25, 2024 · 0 comments

Comments

@jaraco
Copy link
Owner

jaraco commented Sep 25, 2024

As reported in home-assistant/core#123035 (comment), the PlatformDirs.override has no effect.

I'd swear I tested this behavior, but now that I look at the tests in place:

>>> dirs = PlatformDirs(appname='Abode', appauthor=False)
>>> dirs.override(data_path=getfixture('tmp_path') / 'data' / 'dir')
>>> assert dirs.user_data.is_dir()

>>> dirs = PlatformDirs(appname='Abode', appauthor=False)
>>> dirs.override(user_data=pathlib.Path('/tmp/foo'))

They in fact don't assert that override has the intended effect. And worse, one of them doesn't even perform the correct operation (setting data_path instead of user_data).

Applying the following diff reveals the failure:

diff --git a/jaraco/abode/config.py b/jaraco/abode/config.py
index 423dc55..b8e5148 100644
--- a/jaraco/abode/config.py
+++ b/jaraco/abode/config.py
@@ -33,6 +33,8 @@ class PlatformDirs(platformdirs.PlatformDirs):
 
         >>> dirs = PlatformDirs(appname='Abode', appauthor=False)
         >>> dirs.override(user_data=pathlib.Path('/tmp/foo'))
+        >>> 'foo' in str(dirs.user_data)
+        True
         """
         for name, path in kwargs.items():
             vars(self).update({name + '_path': path})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant