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
support an alternate syntax for "not" (as in pytest -m "not stuff"
)
#12226
Comments
about 10 years ago there was such a syntax, it created numerous issues - now we have a regular language and right to my point all of your proposals are incorrect applications of the short argument for thats invalid in any case the syntax before was imho its on ci systems to finally add save ways to invoke things, im -1 on re-adding a mess just to avoid quotes as from personal experience the messes to avoid quotes where so far worse |
I agree. All of your proposed syntaxes come with their own problems - except How is "passing quotes into bash still tricky"? |
to be fair bash in yaml in ci with variable pass-over can sill turn into nightmares the moment one makes a variable quoting mistake as bash is demonstrably hostile to writing correct code in any non-trivial capacity |
Seems like this could be handled by a plugin or a local conftest.py modification. # put this in conftest.py to avoid markers
# Example:
# `pytest --not foo` will deselect `foo` marked tests.
# `pytest --not foo bar` will deselect both `foo` and `bar` marked tests.
# etc.
def pytest_addoption(parser):
parser.addoption('--not', action='store', dest='not_markers', nargs='*',
help='markers to not run')
def pytest_collection_modifyitems(config, items):
not_markers = config.option.not_markers
if not_markers:
# just in case someone calls --not foo, bar
# strip out commas
not_markers = [m.strip(',') for m in not_markers]
selected_items = []
deselected_items = []
for item in items:
found_unwanted_marker = False
for avoid in not_markers:
if item.get_closest_marker(avoid):
found_unwanted_marker = True
if found_unwanted_marker:
deselected_items.append(item)
else:
selected_items.append(item)
config.hook.pytest_deselected(items=deselected_items)
items[:] = selected_items |
I think I need this also, maybe I'll write a plugin |
Bonus. |
What's the problem this feature will solve?
Lots of CI systems heavily rely on bash or various bash scripts. And even tho we're in 2024, passing quotes into bash is still tricky. I would ask that an alternate way of specifying "not", such as :
these would be similar
Describe the solution you'd like
basically an alternate syntax that would not require quotation marks to specify it
Alternative Solutions
Additional context
The text was updated successfully, but these errors were encountered: