def close(self): if self.__connection is not None: try: self.__connection.close() except: # On some condition such as Ubuntu 14.04, the above close() # raises an exception when the rabbitmq-server is stopped. hap.handle_exception() self.__connection = None
def test_handle_exception(self): obj = Gadget() try: raise obj except: exctype, value = hap.handle_exception() self.assertEquals(Gadget, exctype) self.assertEquals(obj, value)