I am trying to run a pytest script like this :
pytest myfile.py -m marker_name -v -s --disable-warnings
pytest.ini contains the marker name as :
[pytest]
markers =
marker_name: run marker_name scenario
But I am getting the above output. The marker seems to have been collected but is deselected. Can anyone provide any insights onto this?
To me it looks like you did not add the marker to the test file at all. From your description how you run the test file, you would only run the tests, marked with the
marker_name
, but you do not have any tests marked correctly.You need to mark the tests with
@pytest.mark.marker_name
.I use for example following marker in my
pytest.ini
file:In my "test_dummy.py" file I use the marker like that:
To exclude the soup tests I run:
To only run the soup tests I do:
See also here: https://docs.pytest.org/en/6.2.x/example/markers.html