def value_in(value, choices):
    """Raise an exception if a value doesn't match one of the given choices."""
    if value not in choices:
        raise ValueError("Expected one of %s, received %r." % (", ".join([repr(choice) for choice in choices]), value)) # pragma: no cover
    return value