Skip to content

Is the value of the log_cli ini option introspectable from conftest.py? #12702

Answered by wimglenn
adigitoleo asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, take a look at config.getini.

if your pyproject.toml has this:

[tool.pytest.ini_options]
log_cli = true

Then your conftest.py can have this:

import pytest

@pytest.hookimpl(trylast=True)
def pytest_configure(config):
    if config.getini("log_cli"):
        print("do my stuff...")

You may also be interested in config.getoption, for retrieving command-line options (these have precedence over ini options).

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@adigitoleo
Comment options

@wimglenn
Comment options

@adigitoleo
Comment options

Answer selected by adigitoleo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants