Closed
Description
I tried to create a class with some test methods with a fixture.
I have a special marker with kwargs that can change behaviour the fixture.
And I want to run this tests with different parameters of this marker.
Unfortunately, all subclass share one method and I every mark affected this method.
Small example:
@pytest.mark.my_marker(status="A")
class TestA(object):
@pytest.mark.my_marker(status="M")
def test_method(self, task_context):
pass
@pytest.mark.my_marker(status="B")
class TestB(TestA):
pass
In result I have 2 tests:
- TestA. test_method
- TestB. test_method
But both test have the same marker with kwargs={"status": "B}
As I understand, pytest.mark
store marker in function object and mark method even if it is applied to class.
So it setup markers:
my_marker(status="M")
my_marker(status="A")
my_marker(status="B")
In this case ability to mark method and class simultaneously looks useless.