def test_bare_caller(): with pytest.raises(ValueError): url = Url() x = str(url) print(x)
def test_path_validation(): url = Url.as_localhost_ssl() with pytest.raises(ValueError): url = url(path='/This is an invalid path')
def test_netloc_parser(): url = Url.as_localhost() x = url._parse_netloc(*[None] * 5) assert x is None
def test_scheme_override(): url = Url.as_localhost_ssl(scheme='ws', port=3000) assert str(url) == 'ws://localhost:3000' url = url(port=3001) assert str(url) == 'ws://localhost:3001'
def test_op_overloading(): url = Url('http://localhost:3333') x = url / 'x' assert x.url == url.url + '/x' x = x & {'q': 'help'} print(x)