( # noqa: PLR0913
monkeypatch: pytest.MonkeyPatch,
root: str | None,
data: str | None,
path: str,
shell: str | None,
prefix: str | None,
)
| 65 | @pytest.mark.parametrize("shell", ["/data/data/com.app/files/usr/bin/sh", "/usr/bin/sh", None]) |
| 66 | @pytest.mark.parametrize("prefix", ["/data/data/com.termux/files/usr", None]) |
| 67 | def test_android_active( # noqa: PLR0913 |
| 68 | monkeypatch: pytest.MonkeyPatch, |
| 69 | root: str | None, |
| 70 | data: str | None, |
| 71 | path: str, |
| 72 | shell: str | None, |
| 73 | prefix: str | None, |
| 74 | ) -> None: |
| 75 | for env_var, value in {"ANDROID_DATA": data, "ANDROID_ROOT": root, "SHELL": shell, "PREFIX": prefix}.items(): |
| 76 | if value is None: |
| 77 | monkeypatch.delenv(env_var, raising=False) |
| 78 | else: |
| 79 | monkeypatch.setenv(env_var, value) |
| 80 | |
| 81 | from platformdirs.android import _android_folder # noqa: PLC0415 |
| 82 | |
| 83 | _android_folder.cache_clear() |
| 84 | monkeypatch.setattr(sys, "path", ["/A", "/B", path]) |
| 85 | |
| 86 | expected = ( |
| 87 | root == "/system" and data == "/data" and shell is None and prefix is None and _android_folder() is not None |
| 88 | ) |
| 89 | if expected: |
| 90 | assert platformdirs._set_platform_dir_class() is Android # noqa: SLF001 |
| 91 | else: |
| 92 | assert platformdirs._set_platform_dir_class() is not Android # noqa: SLF001 |
| 93 | |
| 94 | |
| 95 | def _fake_import( |
nothing calls this directly
no test coverage detected
searching dependent graphs…