def test_logalert(self): for i in range(0, 10): try: raise ValueError('this is the same error 10 times') except: log_exc(i) class CustomException(Exception): pass try: raise CustomException('custom exception') except: log_exc() errors = db.logalert.find() self.assertTrue(errors.count(), 11) mail_all_new()
# python core import time import sys # from this project from logalert import mail_all_new if __name__ == '__main__': # every 5 seconds send all new mails while True: mail_all_new() sys.stdout.write('*') sys.stdout.flush() time.sleep(5)