def _clean_host(self, host): try: validate_hostname(host) except ValidationError as error: raise ValidationError("Invalid hostname: " + error.message) else: return host
def assertAccepts(self, hostname): """Assertion: the validator accepts `hostname`.""" try: validate_hostname(hostname) except ValidationError as e: raise AssertionError(str(e))