class APITestCase(unittest.TestCase):

    def _patchObject(self, module_name, **kwargs):
        patcher = patch(module_name, **kwargs)
mock = patcher.start()
self.patches.append(patcher)
return mock

def setUp(self):
    logging.disable(logging.CRITICAL)
self.patches = []
self.session = self._patchObject('components.ApplicationAPI')
self.database = self._patchObject('txpostgres.txpostgres.Connection')

def tearDown(self):
    for patcher in self.patches:
        patcher.stop()
How to do unit test on Autobahn applications using Twisted Trial?