0

So I am trying to implement an @warn tag. The idea is this test doesn't make an assertion and fail, but instead simply prints out a warning. I see this answer here, but that only explains how to do it on command line or in Behave.ini file, but I don't want to turn it on for all tests, just ones tagged warn. I tried this in my environment file but with no success:

def before_scenario(context, scenario):
    if 'warn' in context.tags:
        # Set to immediately out rather than keep for fail
        stdout_capture = False
        stderr_capture = False

def after_scenario(context, scenario):
    if 'warn' in context.tags:
        stdout_capture = True
        stderr_capture = True
1

I think you need to modify the context, not just create a variable with that name. Unfortunately, even context.stdout_capture = sys.__stdout__ doesn't seem to solve this. It generates a ContextMaskWarning as you are modifying something that behave will, and does, overwrite. Of course you could modify your instance behave to avoid this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.