I am new to python. I have declared one fixture configure_loggers()
with scope as 'session'. Now, I want to use this fixture before another fixture setup_app()
, which is also scoped as 'session'.
Fixture 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)
Fixture 2:
from fixtures.logger_config import configure_loggers
@pytest.fixture(scope='session')
def frapp(configure_loggers, request, context):
start_appium()
# do some other stuff
I have tried to add logging fixture to parameters as well as @pytest.mark.usefixtures('configure_loggers')
. However I am getting following error:
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.
I have tried to put the fixtures in same file as well. But, still getting same error.
How can I debug this issue?
I solved it by doing this import in conftest.py
.
from fixtures.logger_config import configure_loggers