我正在尝试测试我的猎鹰路线,但测试总是失败,看起来我做的一切都是正确的。
我的app.py
import falcon
from resources.static import StaticResource
api = falcon.API()
api.add_route('/', StaticResource())
和我的测试目录tests/static.py
from falcon import testing
import pytest
from app import api
@pytest.fixture(scope='module')
def client():
# Assume the hypothetical `myapp` package has a
# function called `create()` to initialize and
# return a `falcon.API` instance.
return testing.TestClient(api.create())
def test_get_message(client):
result = client.simulate_get('/')
assert result.status_code == 200
请帮助,为什么我得到AttributeError: 'API' object has no attribute 'create'
错误?谢谢。