我使用PyTest在Sanic中运行了以下测试,但是我得到了
未找到灯具“回路”
错误,我按照link中的教程进行操作,其中make应用程序返回Sanic应用程序。
import pytest
import json
from main import make_app
@pytest.yield_fixture
def app():
app = make_app()
yield app
@pytest.fixture
def test_cli(loop, app, test_client):
return loop.run_until_complete(test_client(app))
async def test_fixture_test_client_post(test_cli):
data = {
"urls" : [
"https://images.pexels.com/photos/789380/pexels-photo-789380.jpeg",
"https://images.pexels.com/photos/280204/pexels-photo-280204.jpeg"
]
}
response = await test_cli.post('/v1/images/upload',data=json.dumps(data))
assert response.status == 200
答案 0 :(得分:0)
我卸载了pytest-sanic,然后重新安装并成功运行。
评论中提到的@hoefling,
运行此命令pytest -v --collect-only | grep plugins
显示插件未正确安装