Reputation: 3139
There is a test file with a global marker for each stored test:
from pytest import mark
pytestmark = mark.unit
This works as expected and all of the tests from this file as marked as unit
. However, I'd like to override the mark for a single test, so that it no longer has the unit
marker.
When I use the decorator on the test function that I want to modify, instead of overriding the original marker, it contains both unit
and the new integration
markers:
@mark.integration
def test_integration():
pass
I've checked the marker decorator sources and it seems that it calls store_mark
and has no additional properties that would let me override existing test markers.
Are there any idiomatic solutions to override existing testing marks or should I just store the tests in a separate file?
Upvotes: 3
Views: 1229
Reputation: 1474
I don’t think there is built-in functionality for this. You have a few options:
Implement a plugin that gives you an unmark
decorator. Someone has already tried this but I haven’t tested it.
Or Put all of your unit
tests in a class and decorate the class with the marker.
import pytest
@pytest.mark.unit
class TestUnits:
def test1(self):
pass
@pytest.mark.integration
def integration_test():
pass
Upvotes: 2