def METHOD_NAME(retries_needed, caplog):
    cmd = ["skopeo", "copy", "docker://a", "docker://b"]
    n_tries = 0
    def mock_run(*args, **kwargs):
        nonlocal n_tries
        n_tries += 1
        if n_tries > retries_needed:
            return subprocess.CompletedProcess(
                cmd, 0, stdout=b'some output', stderr=b'some warning'
            )
        else:
            raise subprocess.CalledProcessError(
                1, cmd, output=b'some output', stderr=b'some error'
            )
    (
        flexmock(subprocess)
        .should_receive('run')
        .with_args(cmd, check=True, capture_output=True)
        .times(retries_needed + 1)
        .replace_with(mock_run)
    )
    flexmock(time).should_receive('sleep').times(retries_needed)
    # important: the output shouldn't include 'some warning'
    assert retries.run_cmd(cmd) == b'some output'
    assert caplog.text.count('Running skopeo copy docker://a docker://b') == retries_needed + 1
    assert caplog.text.count(
        'skopeo failed:\n'
        'STDOUT:\n'
        'some output\n'
        'STDERR:\n'
        'some error'
    ) == retries_needed
    assert caplog.text.count('skopeo STDERR:\nsome warning') == 1
    for n in range(retries_needed):
        wait = SUBPROCESS_BACKOFF_FACTOR * 2 ** n
        assert f'Backing off run_cmd(...) for {wait:.1f}s' in caplog.text