Пример #1
0
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 check_file(path, ignore=(), complexity=-1):
    if pep8style.excluded(path):
        return 0
    warning = flakey.check_path(path)
    _set_alt(warning)
    warnings = flakey.print_messages(warning, ignore=ignore)
    warnings += pep8style.input_file(path)
    if complexity > -1:
        warnings += mccabe.get_module_complexity(path, complexity)
    return warnings
Пример #3
0
    def run(self):
        import flakey

        build_py_command = self.get_finalized_command('build_py')
        error_count = 0
        for (_, _, path) in build_py_command.find_all_modules():
            warning = flakey.check_path(path)
            if isinstance(warning, flakey.checker.Checker):
                error_count += flakey.print_messages(warning)
            else:
                raise ValueError("Unexpected check_path result.")

        if error_count:
            raise SystemExit(os.EX_DATAERR)
Пример #4
0
 def test_import_exception_in_scope(self):
     warnings = check(code_import_exception, "(stdin)")
     warnings = print_messages(warnings)
     self.assertEqual(warnings, 0)
Пример #5
0
 def test_exception(self):
     for c in (code, code2, code3):
         warnings = check(code, "(stdin)")
         warnings = print_messages(warnings)
         self.assertEqual(warnings, 0)