Skip to content

caplog: Use 'session' scopeΒ #4502

@MarBra

Description

@MarBra

Hi pytest-experts :)

i like to use the caplog fixture in another fixture with session scope:

import pytest
import logging

@pytest.fixture(scope='session')
def my_log(caplog):
    caplog.set_level(logging.INFO)

def test_foo(my_log):
    pass

This results in the following error:
ScopeMismatch: You tried to access the 'function' scoped fixture 'caplog' with a 'session' scoped request object, involved factories

Metadata

Metadata

Assignees

No one assigned

    Labels

    plugin: capturerelated to the capture builtin pluginplugin: loggingrelated to the logging builtin plugintopic: fixturesanything involving fixtures directly or indirectlytype: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions