def testExtraAttributes(self): task = self.getNewTaskCommand() result = self.getResult(task) attrs = {'str': 'bar', 'int': 2, 'list': ['a','b',3], 'dict': {'val': 'result'}} log = ProcessLog(task.logFile) log.writeLogFooterAndClose(result, attrs) i = 0 with open(task.logFile) as f: for line in f: line = line.strip() if line.startswith('int:'): self.assertEqual(line, 'int: 2') elif line.startswith('str:'): self.assertEqual(line, 'str: bar') elif line.startswith('dict:'): self.assertEqual(line, "dict: {'val': 'result'}") elif line.startswith('list:'): self.assertEqual(line, "list: ['a', 'b', 3]") else: continue i += 1 match = len(attrs) self.assertEqual(i, match, "Expected to match %d lines. Got %d" % (match, i))
def testExtraAttributes(self): task = self.getNewTaskCommand() result = self.getResult(task) attrs = { 'str': 'bar', 'int': 2, 'list': ['a', 'b', 3], 'dict': { 'val': 'result' } } log = ProcessLog(task.logFile) log.writeLogFooterAndClose(result, attrs) i = 0 with open(task.logFile) as f: for line in f: line = line.strip() if line.startswith('int:'): self.assertEqual(line, 'int: 2') elif line.startswith('str:'): self.assertEqual(line, 'str: bar') elif line.startswith('dict:'): self.assertEqual(line, "dict: {'val': 'result'}") elif line.startswith('list:'): self.assertEqual(line, "list: ['a', 'b', 3]") else: continue i += 1 match = len(attrs) self.assertEqual(i, match, "Expected to match %d lines. Got %d" % (match, i))
def testHeaderFooter(self): task = self.getNewTaskCommand() result = self.getResult(task) log = ProcessLog(task.logFile) log.writeLogHeader(task) log.write("Foo\n") log.writeLogFooterAndClose(result)