platformdirs 4.14.0__tar.gz → 4.14.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {platformdirs-4.14.0 → platformdirs-4.14.2}/PKG-INFO +1 -1
  2. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/api.py +3 -3
  3. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/unix.py +4 -1
  4. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/version.py +2 -2
  5. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_api.py +48 -0
  6. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_unix.py +17 -0
  7. {platformdirs-4.14.0 → platformdirs-4.14.2}/.gitignore +0 -0
  8. {platformdirs-4.14.0 → platformdirs-4.14.2}/LICENSE +0 -0
  9. {platformdirs-4.14.0 → platformdirs-4.14.2}/pyproject.toml +0 -0
  10. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/__init__.py +0 -0
  11. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/__main__.py +0 -0
  12. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/_xdg.py +0 -0
  13. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/android.py +0 -0
  14. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/ios.py +0 -0
  15. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/macos.py +0 -0
  16. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/py.typed +0 -0
  17. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/pytest_plugin.py +0 -0
  18. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/testing.py +0 -0
  19. {platformdirs-4.14.0 → platformdirs-4.14.2}/src/platformdirs/windows.py +0 -0
  20. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/conftest.py +0 -0
  21. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_android.py +0 -0
  22. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_comp_with_appdirs.py +0 -0
  23. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_ios.py +0 -0
  24. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_macos.py +0 -0
  25. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_main.py +0 -0
  26. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_pytest_plugin.py +0 -0
  27. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_testing.py +0 -0
  28. {platformdirs-4.14.0 → platformdirs-4.14.2}/tests/test_windows.py +0 -0
  29. {platformdirs-4.14.0 → platformdirs-4.14.2}/tox.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: platformdirs
3
- Version: 4.14.0
3
+ Version: 4.14.2
4
4
  Import-Name: platformdirs
5
5
  Summary: A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`.
6
6
  Project-URL: Changelog, https://platformdirs.readthedocs.io/en/latest/changelog.html
@@ -717,10 +717,10 @@ def _unique(dirs: Iterable[str]) -> Iterator[str]:
717
717
  """:yield: ``dirs`` in order, skipping any directory already yielded."""
718
718
  # Lazy on purpose: under ensure_exists reading a site_*_dir creates it, so draining ``dirs`` up front would
719
719
  # create directories for a caller that stops after the first entry.
720
- seen: set[str] = set()
720
+ seen: set[Path] = set()
721
721
  for path in dirs:
722
- if path not in seen:
723
- seen.add(path)
722
+ if (normalized := Path(path)) not in seen:
723
+ seen.add(normalized)
724
724
  yield path
725
725
 
726
726
 
@@ -25,7 +25,10 @@ if sys.platform == "win32":
25
25
  raise RuntimeError(msg)
26
26
 
27
27
  else:
28
- from os import geteuid
28
+ try:
29
+ from os import geteuid
30
+ except ImportError:
31
+ from os import getuid as geteuid
29
32
 
30
33
 
31
34
  class _UnixDefaults(PlatformDirsABC): # ruff:ignore[too-many-public-methods]
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '4.14.0'
22
- __version_tuple__ = version_tuple = (4, 14, 0)
21
+ __version__ = version = '4.14.2'
22
+ __version_tuple__ = version_tuple = (4, 14, 2)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -444,6 +444,54 @@ def _touch(path: Path) -> Path:
444
444
  return path
445
445
 
446
446
 
447
+ @pytest.mark.parametrize("dirs_class", [pytest.param(Unix, id="unix"), pytest.param(MacOS, id="macos")])
448
+ @pytest.mark.parametrize("kind", [pytest.param("config", id="config"), pytest.param("data", id="data")])
449
+ @pytest.mark.parametrize(
450
+ "suffix", [pytest.param("", id="same"), pytest.param("/", id="slash"), pytest.param("/.", id="dot")]
451
+ )
452
+ def test_equivalent_xdg_dirs_keep_first_spelling(equivalent_xdg_dirs: tuple[Unix | MacOS, str], kind: str) -> None:
453
+ dirs, home = equivalent_xdg_dirs
454
+ assert list(getattr(dirs, f"iter_{kind}_dirs")()) == [home]
455
+
456
+
457
+ @pytest.fixture
458
+ def equivalent_xdg_dirs(
459
+ tmp_path: Path,
460
+ monkeypatch: pytest.MonkeyPatch,
461
+ dirs_class: type[Unix | MacOS],
462
+ kind: str,
463
+ suffix: str,
464
+ ) -> tuple[Unix | MacOS, str]:
465
+ monkeypatch.chdir(tmp_path)
466
+ root = tmp_path.as_posix().removeprefix(tmp_path.drive)
467
+ home = f"{root}{suffix}"
468
+ monkeypatch.setenv(f"XDG_{kind.upper()}_HOME", home)
469
+ monkeypatch.setenv(f"XDG_{kind.upper()}_DIRS", root)
470
+ return dirs_class(), home
471
+
472
+
473
+ @pytest.mark.parametrize("dirs_class", [pytest.param(Unix, id="unix"), pytest.param(MacOS, id="macos")])
474
+ @pytest.mark.parametrize("kind", [pytest.param("config", id="config"), pytest.param("data", id="data")])
475
+ @pytest.mark.parametrize(
476
+ "suffix", [pytest.param("", id="same"), pytest.param("/", id="slash"), pytest.param("/.", id="dot")]
477
+ )
478
+ def test_equivalent_xdg_paths_appear_once(equivalent_xdg_dirs: tuple[Unix | MacOS, str], kind: str) -> None:
479
+ dirs, home = equivalent_xdg_dirs
480
+ assert list(getattr(dirs, f"iter_{kind}_paths")()) == [Path(home)]
481
+
482
+
483
+ @pytest.mark.parametrize("dirs_class", [pytest.param(Unix, id="unix"), pytest.param(MacOS, id="macos")])
484
+ @pytest.mark.parametrize("kind", [pytest.param("config", id="config"), pytest.param("data", id="data")])
485
+ @pytest.mark.parametrize(
486
+ "suffix", [pytest.param("", id="same"), pytest.param("/", id="slash"), pytest.param("/.", id="dot")]
487
+ )
488
+ def test_equivalent_xdg_files_appear_once(equivalent_xdg_dirs: tuple[Unix | MacOS, str], kind: str) -> None:
489
+ dirs, home = equivalent_xdg_dirs
490
+ expected = Path(home) / "app.toml"
491
+ expected.touch()
492
+ assert getattr(dirs, f"find_{kind}_files")("app.toml") == [expected]
493
+
494
+
447
495
  @pytest.mark.parametrize("kind", _EXISTING_KINDS)
448
496
  def test_find_file_returns_user_file(dirs: Unix, kind: str, user_file: Path) -> None:
449
497
  assert getattr(dirs, f"find_{kind}_file")("app.toml") == user_file
@@ -387,6 +387,23 @@ def test_platform_on_win32(monkeypatch: pytest.MonkeyPatch, mocker: MockerFixtur
387
387
  sys.modules["platformdirs.unix"] = prev_unix
388
388
 
389
389
 
390
+ @pytest.mark.parametrize("uid", [0, 1234])
391
+ def test_platform_without_geteuid(
392
+ monkeypatch: pytest.MonkeyPatch, mocker: MockerFixture, runtime_temp_dir: Path, uid: int
393
+ ) -> None:
394
+ monkeypatch.setattr(sys, "platform", "emscripten")
395
+ monkeypatch.delattr(os, "geteuid", raising=False)
396
+ getuid = mocker.patch("os.getuid", return_value=uid, create=True)
397
+ importlib.reload(unix)
398
+
399
+ assert unix.geteuid is getuid
400
+ dirs = unix.Unix(appname="app")
401
+ with _fallback_warning(expected=True):
402
+ assert Path(dirs.user_runtime_dir) == runtime_temp_dir / f"runtime-{uid}" / "app"
403
+ config_dir = unix.Unix(appname="app", use_site_for_root=True).user_config_dir
404
+ assert Path(config_dir) == Path("/etc/xdg/app" if uid == 0 else dirs.user_config_dir)
405
+
406
+
390
407
  @pytest.mark.skipif(sys.platform == "win32", reason="Windows ignores POSIX mode bits")
391
408
  @pytest.mark.parametrize(
392
409
  ("existing_mode", "ensure_exists", "expected_mode"),
File without changes
File without changes
File without changes