def testshouldHaveItsOwnColor(self): fh = open('config','w') fh.write(self.logname+'='+'green\n') fh.close() properties = Property('config') properties.parse_properties() log = Log(self.logname,properties) log.openLog() self.assertTrue(log.ownOutputColor) log.closeLog() os.remove(self.config)
def testReportResumeForTwoDifferentLogs(self): log = Log('out.log') log2 = Log('out2.log') arrayLogs = [log, log2] fh = log.openLog() logcolors = LogColors() message = Message(logcolors) resume = reporting.Resume(arrayLogs) for anylog in arrayLogs: self.readAndUpdateLines(anylog,message,resume) outlogReport = resume.logsReport[log.path] expectedOutLogErrorReport = 'error> not so wrong' gotLogTrace = outlogReport['ERROR'][0].split('=>> ')[1] self.assertEquals(expectedOutLogErrorReport, gotLogTrace)
def testMessage(self): logcolors = LogColors() #using default colors termcolors = TermColorCodes() target = None notifier = notifications.Print() message = Message(logcolors,target) log = Log(self.logfile) log.openLog() sys.stdout = Writer() #testing Colors with default pauseModes for count in range(len(self.someLogTraces)): line = log.readLine() line = line.rstrip() level = line.split('>') message.parse(line, log) output = logcolors.getLevelColor(level[0])+line+termcolors.reset notifier.notify(message,log) self.assertTrue(output in sys.stdout.captured) line = log.readLine() self.assertEqual('',line) message.parse(line, log) self.assertFalse(notifier.notify(message,log))
def openLog(self): log = Log(self.logname) log.openLog() return log