def METHOD_NAME(
    self,
    *,
    user: str,
    service: str,
    populate: bool,
    existing_keyring_path: Optional[str],
    use_os_credential_store: bool,
):
    existing_keyring_dir = Path(existing_keyring_path).parent if existing_keyring_path else None
    temp_dir = existing_keyring_dir or tempfile.mkdtemp(prefix="test_keyring_wrapper")
    mock_supports_os_passphrase_storage_patch = patch("chia.util.keychain.supports_os_passphrase_storage")
    mock_supports_os_passphrase_storage = mock_supports_os_passphrase_storage_patch.start()
    # Patch supports_os_passphrase_storage() to return use_os_credential_store
    mock_supports_os_passphrase_storage.return_value = use_os_credential_store
    mock_configure_backend_patch = patch.object(KeyringWrapper, "_configure_backend")
    mock_configure_backend = mock_configure_backend_patch.start()
    setup_mock_file_keyring(mock_configure_backend, temp_dir, populate=populate)
    keychain = Keychain(user=user, service=service)
    keychain.keyring_wrapper = KeyringWrapper(keys_root_path=Path(temp_dir))
    # Stash the temp_dir in the keychain instance
    keychain._temp_dir = temp_dir  # type: ignore
    # Stash the patches in the keychain instance
    keychain._mock_supports_os_passphrase_storage_patch = mock_supports_os_passphrase_storage_patch  # type: ignore
    keychain._mock_configure_backend_patch = mock_configure_backend_patch  # type: ignore
    return keychain