Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not retrieve caplog results in pytest-bdd specifications #597

Open
jruizaranguren opened this issue Jan 27, 2023 · 0 comments
Open

can not retrieve caplog results in pytest-bdd specifications #597

jruizaranguren opened this issue Jan 27, 2023 · 0 comments

Comments

@jruizaranguren
Copy link

pytest caplog fixture enables the capture of logs so they can be used in assertions.

It seems that py.test bdd steps are capturing out streams somehow so this information is lost. An example of test that fails:

"""we can verify logs feature tests."""

import logging
from pytest_bdd import (
    scenario,
    then,
    when,
)

@scenario('log.feature', 'Logs are retrieved')
def test_logs_are_retrieved():
    """Logs are retrieved."""


@when('user performs an auditable action', target_fixture="logs")
def _(caplog):
    """user performs an auditable action."""
    logging.info("log this")
    return caplog


@then('action is audited')
def _(logs):
    """action is audited."""
    assert logs.records
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant