import unittest import alert_factory class Mock_Alert() : def __init__(self, *args) : self.args = args class Mock_Logger() : def __init__(self) : self.info = self.log self.warn = self.log self.warning = self.log self.error = self.log self.debug = self.log def log(self, *args, **kwargs) : print(args, kwargs) class Test_Alert_Factory(unittest.TestCase) : def setUp(self) : self.was = alert_factory.Alert alert_factory.Alert = Mock_Alert def tearDown(self) : alert_factory.Alert = self.was def test(self) : af = alert_factory.Alert_Factory(None, Mock_Logger()) alert = af.build(0, 5, None, "tagA, tagB", False, "tagC, tagD") self.assertTrue(type(alert) == Mock_Alert) if __name__ == "__main__" : unittest.main()