Пример #1
0
 def setUpClass(cls):
     cls.linter_class = PyLinter
     cls.mixin = PyLinter.__bases__[1]
     cls.mixin_name = PyLinter.__bases__[1].__name__
     linter = PyLinter()
     linter._do_load()
     cls.linter = linter
Пример #2
0
def check_with_pylint(fname):
	from pylint.lint import PyLinter
	linter = PyLinter()
	linter._do_load()
	collector = linter._reporters['collector']()
	linter.set_reporter(collector)
	check = linter._parallel_check([fname])
	results = []
	for msg in linter.reporter.messages:
		module_object = msg.module
		if msg.obj:
			module_object += ".%s" % msg.obj
		message = "[%s] %s %s" % (msg.symbol, module_object, msg.msg)
		results.append((message, msg.line))
		
	return results
Пример #3
0
    def test_do_load(self):
        self.assertTrue(hasattr(self.mixin, '_do_load'))
        self.assertTrue(hasattr(self.linter, '_do_load'),
                        'PyLinter doesnt have _do_load')

        preloaded = PyLinter()
        self.assertFalse(preloaded.config.reports)
        self.assertLessEqual(len(preloaded.cfgfile_parser._sections), 5,
                             'cfgfile_parser already loaded')
        self.assertEqual(len(preloaded._dynamic_plugins), 0)

        preloaded._do_load()
        self.assertTrue(
            preloaded.config.reports,
            '"reports" option for PyLinter.config not modified from default')
        self.assertGreaterEqual(len(preloaded.cfgfile_parser._sections), 5)
        self.assertGreater(len(preloaded._dynamic_plugins), 0)