我是python的新手。我已宣布一个夹具configure_loggers()
,范围为'session'。现在,我想在另一个夹具setup_app()
之前使用这个夹具,它也是'session'。
夹具1:
@pytest.fixture(scope='session')
def configure_loggers(request):
LOGGER.setLevel(logging.WARNING)
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
logging.getLogger().setLevel(logging.INFO)
夹具2:
from fixtures.logger_config import configure_loggers
@pytest.fixture(scope='session')
def frapp(configure_loggers, request, context):
start_appium()
# do some other stuff
我试图在参数和@pytest.mark.usefixtures('configure_loggers')
上添加日志夹具。但是我收到以下错误:
fixture 'configure_loggers' not found
> available fixtures: cache, capfd, caplog, capsys, capturelog, context, doctest_namespace, enable_voice, frapp, launch_app, login, metadata, monkeypatch, pytestconfig, record_xml_property, recwarn, skip_tests_for_ios, tmpdir, tmpdir_factory
> use 'pytest --fixtures [testpath]' for help on them.
我也尝试将灯具放在同一个文件中。但是,仍然得到同样的错误。
我该如何调试此问题?
我将导入from fixtures.logger_config import configure_loggers
添加到conftext.py
。夹具仍在单独的文件中。