pytest-only
pytest-only copied to clipboard
Support for mark.single to exclude even other mark.only tests
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)