Skip to content

Support for mark.single to exclude even other mark.only tests #3

Description

@theY4Kman

In a large codebase, I often set pytest.mark.only on the feature I'm working on, so I don't run the whole suite every time. However, there are a few times when I want to dig in to a single test. It'd be nice to not have to fall back to -k filter in those cases.

I've been playing with this for now:

def pytest_collection_modifyitems(config, items):
    single, only, other = [], [], []
    for item in items:
        if item.get_marker('single'):
            l = single
        elif item.get_marker('only'):
            l = only
        else:
            l = other
        l.append(item)

    if single:
        other += only
        only = single

    if only:
        items[:] = only
        if other:
            config.hook.pytest_deselected(items=other)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions