Skip to content

CliRunner does not capture logging output on stdout #854

@blueyed

Description

@blueyed

Is this expected?

It feels like a missing feature, so I'd be happy to provide it giving some pointers.

My test:

def test_cli_run_with_args(runner):
    result = runner.invoke(cli.main, ['run', 'printf', '%s', '--'])
    …

And in the run command I have:

logger.warn('The temporary profile file (%s) has not been created.',
            profile_file_name)

Where logger is logger = logging.getLogger('covimerage'), which gets setup in __init__.py:

logger = logging.getLogger('covimerage')
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler(sys.stdout))

When run manually the warning shows up.

It also shows up in pytest's Captured stdout call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions