forked from tox-dev/platformdirs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MacOS: Implement XDG for MacOS (tox-dev#4)
- Loading branch information
Showing
8 changed files
with
141 additions
and
16 deletions.
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
Empty file.
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,24 @@ | ||
from platformdirs.macos import MacOS | ||
from platformdirs.unix import Unix | ||
|
||
PARAMS = { | ||
"no_args": {}, | ||
"app_name": {"appname": "foo"}, | ||
"app_name_with_app_author": {"appname": "foo", "appauthor": "bar"}, | ||
"app_name_author_version": { | ||
"appname": "foo", | ||
"appauthor": "bar", | ||
"version": "v1.0", | ||
}, | ||
"app_name_author_version_false_opinion": { | ||
"appname": "foo", | ||
"appauthor": "bar", | ||
"version": "v1.0", | ||
"opinion": False, | ||
}, | ||
} | ||
|
||
OS = { | ||
"darwin": MacOS, | ||
"unix": Unix, | ||
} |
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,35 @@ | ||
import os | ||
from pathlib import Path | ||
from typing import Any, Dict, Tuple, Union | ||
|
||
import pytest | ||
from _pytest.fixtures import SubRequest | ||
from pytest_mock import MockerFixture | ||
|
||
from platformdirs.macos import MacOS | ||
from platformdirs.unix import SUPPORTS_XDG, Unix | ||
|
||
from .common import OS, PARAMS | ||
|
||
|
||
@pytest.mark.parametrize("params", PARAMS.values(), ids=PARAMS.keys()) | ||
@pytest.mark.parametrize("klass", OS.values(), ids=OS.keys()) | ||
@pytest.mark.parametrize( | ||
"case", | ||
SUPPORTS_XDG.items(), | ||
ids=(s.lower() for s in SUPPORTS_XDG.keys()), | ||
) | ||
def test_xdg_compliance_on_unix( | ||
mocker: MockerFixture, | ||
params: Dict[str, Any], | ||
klass: Union[MacOS, Unix], | ||
case: Tuple[str, str], | ||
mock_environ: Dict[str, str], | ||
mock_homedir: Path, | ||
): | ||
func, key = case | ||
prefix = mock_environ[key] = os.path.expanduser(f"~/{func}") | ||
|
||
result: str = getattr(klass(**params), func) | ||
|
||
assert result.startswith(prefix) |