首页 文章

夹具'loop'未找到

提问于
浏览
0

我使用PyTest在Sanic中运行以下测试,但我得到了

夹具'循环'未找到

错误,我按照link中的教程在make app中返回Sanic app .

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

1 回答

  • 0

    我卸载了pytest-sanic,并重新安装并且工作正常 .

    正如@hoefling在评论中提到的,

    运行此命令 pytest -v --collect-only | grep plugins 表明该插件未正确安装

相关问题