Skip to content

Is there a way to filter tests based on something you pass to a CLI option? #10498

Answered by f00dog-x300
f00dog-x300 asked this question in Q&A
Discussion options

You must be logged in to vote

I found the answer myself. I have to utilize the pytest_ignore_collect hook. Something like :

def pytest_ignore_collect(path, config):
    """attemts to skip test based on path"""
    if config.getoption("suite") == "one":
        if "test_suite_1/" in str(path):
            return True
    elif config.getoption("suite") == "two":
        if "test_suite_2/" in str(path):
            return True

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by f00dog-x300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant