I'm using @pytest.mark
to uniquely identify specific tests, therefore I created my custom marker.
@pytest.mark.key
I'm using it as such:
@pytest.mark.key("test-001")
def test_simple(self):
self.passing_step()
self.passing_step()
self.passing_step()
self.passing_step()
assert True
Now from the console I would like to run all tests with the marked key "test-001". How can I achieve this?
What i'm looking for is something like this:
pypi.org/project/pytest-jira/0.3.6
where a test can be mapped to a Jira key. I looked at the source code for the link but i'm unsure how to achieve it in order for me to run specific tests. Say I only wanna run the test with the key "test-001".
Pytest does not provide this out of the box. You can filter by marker names using the
-m
option, but not by marker attributes.You can add your own option to filter by keys, however. Here is an example:
conftest.py
Now you run something like
to only run the tests with that marker attribute.
Note that this will still show the overall number of tests as collected, but run only the filtered ones. Here is an example:
test_key.py