falcon, AttributeError: 'API' object has no attribute 'create'

人走茶凉 提交于 2019-12-05 23:32:53

You are missing the hypothetical create() function in your app.py.

Your app.py should look like the following:

import falcon
from resources.static import StaticResource

def create():
    api = falcon.API()
    api.add_route('/', StaticResource()) 
    return api

api = create()

Then in your tests/static.py should look like:

from falcon import testing
import pytest
from app import create


@pytest.fixture(scope='module')
def client():
    return testing.TestClient(create())

def test_get_message(client):
    result = client.simulate_get('/')
    assert result.status_code == 200
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!