Executing tests that have skip marks #13311
Replies: 3 comments 5 replies
-
| 
         There's no builtin feature for that as typically that's done via xfail/run  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Also, I can't find anything that allows to remove markers dynamically. The only related stuff I found is here - #3324  | 
  
Beta Was this translation helpful? Give feedback.
-
| 
         Tested on pytest 8.x Python 3.11/3.12. # conftest.py
import pytest
def pytest_collection_modifyitems(config, items):
    for item in items:
        marks = [m for m in getattr(item, "own_markers", []) if m.name not in ("skip", "skipif")]
        if len(marks) != len(getattr(item, "own_markers", [])):
            item.own_markers[:] = marks
            item.add_marker(pytest.mark.xfail(reason="was skip or skipif"))  # drop this to run them normally
#should work fine with recent pytest versions
 | 
  
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to run tests with skip and skipif marks without changing tests code.
Example,
And I want
pytestto execute it without removing theskipdecorator in the code.Something like
Beta Was this translation helpful? Give feedback.
All reactions