I would update whole block with this:

```sh
# run tests with a CalDAV server.
if [[ "$@" == *RUN_CALDAV_SERVER=1* ]] ; then
  VIRTUAL_ENV=`which virtualenv`
  RADICALE=`which radicale`
  PIP=`which pip`

  if [ ! -x "$VIRTUAL_ENV" ] ; then
    if [ ! -x "$PIP" ]; then
      echo "$SELF: Unable to find pip; can't install 'virtualenv'"
      exit 1
    fi

    # Go to the isolated Python environment.
    echo "Install Virtualenv."
    sudo pip install virtualenv
    virtualenv ENV
    source ./ENV/bin/activate
  fi

  if [ ! -x "$RADICALE" ] ; then
    if [ ! -x "$PIP" ] ; then
      echo "$SELF: Unable to find pip; can't install 'radicale'"
      exit 1
    fi

    # Install the Radicale CalDAV server for
    # doing testing things with Calendar App.
    # See more in http://radicale.org.
    echo "Install Radicale."
    sudo pip install radicale
  fi
fi
```

that would give clear error messages and would also only install dependencies if needed.

installing `pip` is not so straightforward (and safe) so I decided to not automate that. - error message will at least tell user why it fails.