pytest explicitly mark tests

Viewed 153

I'd like to make test names in pytest more readable by avoiding repetition of the word 'test', e.g.:

import pytest

def add(a, b):
    return a + b

class TestAdd:
    @pytest.mark('something?')
    def one_and_one_is_two(self):
         assert add(1, 1) == 2

Renaming the test to test_one_and_one_is_two would be functionally correct, but will result in the name including 'test' twice, which is undesirable. Is there a mark or other mechanism to explicitly mark the test as a test, and hence avoid the need to rely on the test discovery rules?

I know I can override the default discovery rules, but this means specifying another rule, which wouldn't satisfy all the test names I'll need.

0 Answers
Related