-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Fix macos user_site_dir #137
Merged
gaborbernat
merged 11 commits into
tox-dev:main
from
ThomasWaldmann:fix-trailing-slash-macos
Feb 6, 2023
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9782dd6
*_config_dir -> "*/Library/Application Support" (macOS), fixes #98
ThomasWaldmann 528760c
remove the outdated test skips for macOS
ThomasWaldmann 2e2a00b
add CHANGES.rst entry
ThomasWaldmann df86ca9
cleanup trailing slashes (macOS), fixes #134
ThomasWaldmann 496ada1
add macOS tests
ThomasWaldmann fe50a62
simplify code: config dir is the same as the data dir (macOS)
ThomasWaldmann 6f0f0d6
add CHANGES.rst entry
ThomasWaldmann 520f670
bump date
ThomasWaldmann 63d035c
skip macOS-specific tests if not on macOS
ThomasWaldmann 9f6b584
PR feedback
gaborbernat f924ca5
PR feedback
gaborbernat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from __future__ import annotations | ||
|
||
import os | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
from platformdirs.macos import MacOS | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"params", | ||
[ | ||
{}, | ||
{"appname": "foo"}, | ||
{"appname": "foo", "version": "v1.0"}, | ||
], | ||
ids=[ | ||
"no_args", | ||
"app_name", | ||
"app_name_version", | ||
], | ||
) | ||
def test_macos(params: dict[str, Any], func: str) -> None: | ||
result = getattr(MacOS(**params), func) | ||
|
||
home = os.path.expanduser("~") | ||
suffix_elements = [] | ||
if "appname" in params: | ||
suffix_elements.append(params["appname"]) | ||
if "version" in params: | ||
suffix_elements.append(params["version"]) | ||
if suffix_elements: | ||
suffix_elements.insert(0, "") | ||
suffix = "/".join(suffix_elements) | ||
|
||
expected_map = { | ||
"user_data_dir": f"{home}/Library/Application Support{suffix}", | ||
"site_data_dir": f"/Library/Application Support{suffix}", | ||
# Please note that the config dirs are NOT */Library/Preferences! | ||
# For details see: https://github.com/platformdirs/platformdirs/issues/98 | ||
"user_config_dir": f"{home}/Library/Application Support{suffix}", | ||
"site_config_dir": f"/Library/Application Support{suffix}", | ||
"user_cache_dir": f"{home}/Library/Caches{suffix}", | ||
"user_state_dir": f"{home}/Library/Application Support{suffix}", | ||
"user_log_dir": f"{home}/Library/Logs{suffix}", | ||
"user_documents_dir": f"{home}/Documents", | ||
"user_runtime_dir": f"{home}/Library/Caches/TemporaryItems{suffix}", | ||
} | ||
expected = expected_map[func] | ||
|
||
assert result == expected |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
guess this should avoid somebody changing this back to the wrong dirs again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this comment? The test itself is enough with the git blame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering this was initially correct, then broken for platformdirs 2.0.0 and now back in the initial correct state, I would strongly suggest we keep that comment, so that this never happens again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree and I'ld appreciate another persons opinion here.
You can't just assume that the next guy who breaks this will do git blame or a lot of other research first. Otherwise the breakage at 2.0.0 would also not have happened.
And if such a comment would have been there before the 2.0.0 breakage, we would not have had all 2.x.x releases wrong on macOS and also would not have had 2 incompatible/breaking releases in total for macOS users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look, the maintainer's opinion trumps your opinion 😊 at the end of the day.