How to use the rfc3986.exceptions function in rfc3986

To help you get started, we’ve selected a few rfc3986 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-hyper / rfc3986 / tests / test_parseresult.py View on Github external
def test_raises_invalid_port_non_strict_parse(self, port):
        with pytest.raises(exceptions.InvalidPort):
            pr.ParseResultBytes.from_string(
                "https://httpbin.org:{0}/get".format(port), strict=False
            )
github python-hyper / rfc3986 / tests / test_validators.py View on Github external
def test_validating_rfc_4007_ipv6_zone_ids():
    """Verify that RFC 4007 IPv6 Zone IDs are invalid
    host/authority but after normalization are valid
    """
    uri = rfc3986.uri_reference("http://[::1%eth0]")
    with pytest.raises(exceptions.InvalidComponentsError):
        validators.Validator().check_validity_of("host").validate(uri)

    uri = uri.normalize()
    assert uri.host == "[::1%25eth0]"

    validators.Validator().check_validity_of("host").validate(uri)
github python-hyper / rfc3986 / tests / test_validators.py View on Github external
def test_forbidden_passwords(uri):
    """Verify that passwords are disallowed."""
    validator = validators.Validator().forbid_use_of_password()
    with pytest.raises(exceptions.PasswordForbidden):
        validator.validate(uri)
github frictionlessdata / tableschema-py / tableschema / types / string.py View on Github external
def cast_string(format, value, **options):
    if not isinstance(value, six.string_types):
        return ERROR
    if format == 'uri':
        uri = _uri_from_string(value)
        try:
            _uri_validator.validate(uri)
        except rfc3986.exceptions.ValidationError:
            return ERROR
    elif format == 'email':
        if not re.match(_EMAIL_PATTERN, value):
            return ERROR
    elif format == 'uuid':
        try:
            uuid.UUID(value, version=4)
        except Exception:
            return ERROR
    elif format == 'binary':
        try:
            base64.b64decode(value)
        except Exception:
            return ERROR
    return value