raise exception for invalid param syntax
This commit is contained in:
parent
9bc1abcd00
commit
770a8fb288
|
@ -93,6 +93,8 @@ class Router:
|
|||
pattern = 'string'
|
||||
if ':' in parameter_string:
|
||||
name, pattern = parameter_string.split(':', 1)
|
||||
if not name:
|
||||
raise ValueError("Invalid parameter syntax: {}".format(parameter_string))
|
||||
|
||||
default = (str, pattern)
|
||||
# Pull from pre-configured types
|
||||
|
|
|
@ -71,6 +71,16 @@ def test_route_strict_slash():
|
|||
request, response = app.test_client.post('/post')
|
||||
assert response.status == 404
|
||||
|
||||
def test_route_invalid_parameter_syntax():
|
||||
with pytest.raises(ValueError):
|
||||
app = Sanic('test_route_invalid_param_syntax')
|
||||
|
||||
@app.get('/get/<:string>', strict_slashes=True)
|
||||
def handler(request):
|
||||
return text('OK')
|
||||
|
||||
request, response = app.test_client.get('/get')
|
||||
|
||||
def test_route_strict_slash_default_value():
|
||||
app = Sanic('test_route_strict_slash', strict_slashes=True)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user