blob: cf39d1b94636be421a3aaf8a50e716fd60c030fe [file] [log] [blame] [edit]
"""Tests for pylint."""
import os
import sys
import unittest
from cq.scripts.helpers import pylint
class PylintTest(unittest.TestCase):
def testParseLintOutput(self):
"""Tests parsing lint output."""
py_file = 'path/to/file_one.py'
lines = [
'************* Module path.to.file_one',
'path/to/file_one.py:37: [E0001(error-1), RunPylint] First error.',
'path/to/file_one.py:50: [E(error/type2), RunPylint] Second error.',
'path/to/file_one.py:1: [W1201(warningXYZ), RunPylint] Warning.',
]
result_comments = pylint.ParseLint(lines)
comments = result_comments[py_file]
self.assertIsNotNone(comments)
self.assertEqual(3, len(comments))
comment = comments[0]
self.assertEqual('37', comment['line'])
self.assertEqual('First error. [error-1]', comment['message'])
comment = comments[1]
self.assertEqual('50', comment['line'])
self.assertEqual('Second error. [error/type2]', comment['message'])
comment = comments[2]
self.assertEqual('1', comment['line'])
self.assertEqual('Warning. [warningXYZ]', comment['message'])
if __name__ == '__main__':
unittest.main()