(mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch)
| 110 | |
| 111 | |
| 112 | def test_android_folder_from_p4a(mocker: MockerFixture, monkeypatch: pytest.MonkeyPatch) -> None: |
| 113 | from platformdirs.android import _android_folder # noqa: PLC0415 |
| 114 | |
| 115 | mocker.patch.dict(sys.modules, {"jnius": MagicMock(side_effect=ModuleNotFoundError)}) |
| 116 | monkeypatch.delitem(__import__("sys").modules, "jnius") |
| 117 | |
| 118 | _android_folder.cache_clear() |
| 119 | |
| 120 | get_absolute_path = MagicMock(return_value="/A") |
| 121 | get_parent_file = MagicMock(getAbsolutePath=get_absolute_path) |
| 122 | get_files_dir = MagicMock(getParentFile=MagicMock(return_value=get_parent_file)) |
| 123 | get_application_context = MagicMock(getFilesDir=MagicMock(return_value=get_files_dir)) |
| 124 | m_activity = MagicMock(getApplicationContext=MagicMock(return_value=get_application_context)) |
| 125 | mocker.patch.dict(sys.modules, {"android": MagicMock(mActivity=m_activity)}) |
| 126 | |
| 127 | result = _android_folder() |
| 128 | assert result == "/A" |
| 129 | assert get_absolute_path.call_count == 1 |
| 130 | |
| 131 | assert _android_folder() is result |
| 132 | assert get_absolute_path.call_count == 1 |
| 133 | |
| 134 | |
| 135 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected
searching dependent graphs…