class TestBase(unittest.TestCase):

    def __init__(self, *args, **kwargs):
        super(TestBase, self).__init__(*args, **kwargs)
self.helper = None
if self.__class__ != TestBase:
    self.run = unittest.TestCase.run.__get__(self, self.__class__)
else:
    self.run = lambda self, *args, **kwargs: None

def newHelper(self):
    raise NotImplementedError()

def setUp(self):
    print('shared for all subclasses')
self.helper = self.newHelper()

def testFoo(self):
    print('shared for all subclasses')


class Test1(TestBase):

    def newHelper(self):
        return HelperObject1()


class Test2(TestBase):

    def newHelper(self):
        return HelperObject2()
abstract test case using python unittest