How to use the rfc3986.validators.Validator 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_validators.py View on Github external
def test_invalid_uri_with_invalid_path(invalid_uri):
    """Verify we catch multiple invalid components."""
    uri = rfc3986.uri_reference(invalid_uri)
    uri = uri.copy_with(path="#foobar")
    with pytest.raises(exceptions.InvalidComponentsError):
        validators.Validator().check_validity_of("host", "path",).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 python-hyper / rfc3986 / tests / test_validators.py View on Github external
def test_missing_host_component(uri):
    """Verify that missing host components cause errors."""
    validators.Validator().validate(uri)

    validator = validators.Validator().require_presence_of("host")
    with pytest.raises(exceptions.MissingComponentError):
        validator.validate(uri)
github python-hyper / rfc3986 / tests / test_validators.py View on Github external
def test_missing_path_component(uri):
    """Verify that missing path components cause errors."""
    validator = validators.Validator().require_presence_of("path")
    with pytest.raises(exceptions.MissingComponentError):
        validator.validate(uri)
github python-hyper / rfc3986 / tests / test_validators.py View on Github external
def test_checking_validity_of_component():
    """Verify that we validate components we're validating."""
    with pytest.raises(ValueError):
        validators.Validator().check_validity_of("frob")