我有一个设置的 api
import hug
API = hug.API(__name__).http.base_url='/api'
@hug.get('/hello-world', versions=1)
def hello_world(response):
return hug.HTTP_200
我正在尝试使用 PyTest 对其进行测试。
我正在尝试使用
import pytest
import hug
from myapi import api
...
def test_hello_world_route(self):
result = hug.test.get(myapp, 'v1/hello-world')
assert result.status == hug.HTTP_200
如何测试已http.base_url
配置的拥抱路由?
404
无论路由路径如何,我都会收到错误消息。我试过了
/api/v1/hello-world
api/v1/hello-world
v1/hello-world
/v1/hello-world
如果我删除hug.API().http.base_url
设置然后v1/hello-world
工作正常,但我的要求是有一个base_url
设置。
我已经查看了官方 hug github repo 和各种在线资源(例如 ProgramTalk)上的文档,但我没有取得太大的成功。
有什么建议吗?