You can use Django's @tag decorator as a criteria to be used in the setUp method to skip if necessary.
# import tag decorator
from django.test.utils import tag
# The test which you want to skip setUp
@tag('skip_setup')
def test_mytest(self):
assert True
def setUp(self):
method = getattr(self,self._testMethodName)
tags = getattr(method,'tags', {})
if 'skip_setup' in tags:
return #setUp skipped
#do_stuff if not skipped
Besides skipping you can also use tags to do different setups.
P.S. If you are not using Django, the source code for that decorator is really simple:
def tag(*tags):
"""
Decorator to add tags to a test class or method.
"""
def decorator(obj):
setattr(obj, 'tags', set(tags))
return obj
return decorator