def METHOD_NAME(
    self, readurl, sleep, fail_count, exception, caplog_text
):
    """Retries backoff before failing to get Azure.identity_doc"""
    def fake_someurlerrors(url, headers, timeout):
        if readurl.call_count <= fail_count:
            return http.HTTPResponse(
                code=700 + readurl.call_count,
                headers={},
                body="funky error msg",
                json_dict={},
                json_list=[],
            )
        if "attested" in url:
            return http.HTTPResponse(
                code=200,
                headers={"header": "stuff"},
                body="",
                json_dict={"signature": "attestedWOOT!==="},
                json_list=[],
            )
        elif "compute" in url:
            return http.HTTPResponse(
                code=200,
                headers={"header": "stuff"},
                body="",
                json_dict={"computekey": "computeval"},
                json_list=[],
            )
        raise AssertionError("Unexpected url requested {}".format(url))
    readurl.side_effect = fake_someurlerrors
    instance = UAAutoAttachAzureInstance()
    if exception:
        with pytest.raises(exceptions.CloudMetadataError):
            instance.identity_doc
    else:
        assert {
            "pkcs7": "attestedWOOT!===",
            "compute": {"computekey": "computeval"},
        } == instance.identity_doc
    expected_sleep_calls = [mock.call(1), mock.call(1), mock.call(1)]
    assert expected_sleep_calls == sleep.call_args_list
    expected_logs = [
        "An error occurred while talking the the cloud metadata service: 701 - funky error msg: Retrying 3 more times.",  # noqa: E501
        "An error occurred while talking the the cloud metadata service: 702 - funky error msg: Retrying 2 more times.",  # noqa: E501
        "An error occurred while talking the the cloud metadata service: 703 - funky error msg: Retrying 1 more times.",  # noqa: E501
    ]
    logs = caplog_text()
    for log in expected_logs:
        assert log in logs