示例#1
0
文件: main.py 项目: gfreezy/flake8
def check_code(code, ignore=(), complexity=-1):
    warning = flakey.check(code, '<stdin>')
    _set_alt(warning)
    warnings = flakey.print_messages(warning, ignore=ignore, code=code)
    warnings += pep8style.input_file('-', lines=code.split('\n'))
    if complexity > -1:
        warnings += mccabe.get_code_complexity(code, complexity)
    return warnings
示例#2
0
 def test_import_exception_in_scope(self):
     warnings = check(code_import_exception, "(stdin)")
     warnings = print_messages(warnings)
     self.assertEqual(warnings, 0)
示例#3
0
 def test_exception(self):
     for c in (code, code2, code3):
         warnings = check(code, "(stdin)")
         warnings = print_messages(warnings)
         self.assertEqual(warnings, 0)