在pytest fixtures中导入应用程序时出错

2024-06-01 20:47:27 发布

您现在位置:Python中文网/ 问答频道 /正文

client_fixture.py

import pytest

from app.apis import api
from app import create_app


@pytest.fixture
def app_client(credentials, redis_cred_setup):
    app = create_app(credentials['app_config_name'])
    api.init_app(app)

    client = app.test_client()
    return client

我在app包中的create_app()内有fixture和函数__init__.py

但是这个固定装置产生了一个错误

ImportError: Error importing plugin "client_fixtures": No module named 'app'

包装结构

^{pr2}$

Maybe it will be helpful

当我用PyCharm运行测试时,一切正常 我只需在tests文件夹上单击鼠标右键并执行'Runpy.测试测试中


Tags: frompyimportredisclientapiappinit