def test_dynamic_route_number():
app = Sanic('test_dynamic_route_int')
results = []
@app.route('/weight/<weight:number>')
async def handler(request, weight):
results.append(weight)
return text('OK')
request, response = sanic_endpoint_test(app, uri='/weight/12345')
assert response.text == 'OK'
assert type(results[0]) is float
request, response = sanic_endpoint_test(app, uri='/weight/1234.56')
assert response.status == 200
request, response = sanic_endpoint_test(app, uri='/weight/1234-56')
assert response.status == 404
test_routes.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录