Exemplo n.º 1
0
    def test_pep8():
        arglist = [
            '--statistics',
            '--filename=*.py',
            '--show-source',
            '--benchmark',
            '--repeat',
            '--show-pep8',
            #'--qq',
            #'-v',
            BASE_DIR,
        ]

        options, args = pep8.process_options(arglist)
        runner = pep8.input_file

        for path in args:
            if os.path.isdir(path):
                pep8.input_dir(path, runner=runner)
            elif not pep8.excluded(path):
                options.counters['files'] += 1
                runner(path)

        pep8.print_statistics()
        errors = pep8.get_count('E')
        warnings = pep8.get_count('W')
        message = 'pep8: %d errors / %d warnings' % (errors, warnings)
        print(message)
        assert errors + warnings == 0, message
Exemplo n.º 2
0
def test_pep8():
    arglist = [
        "--statistics",
        "--filename=*.py",
        "--show-source",
        "--repeat",
        "--exclude=SVGdraw.py",
        "--ignore=E302,E701",
        #"--show-pep8",
        #"-qq",
        #"-v",
        BASE_DIR,
    ]

    options, args = pep8.process_options(arglist)
    runner = pep8.input_file

    for path in args:
        if isdir(path):
            pep8.input_dir(path, runner=runner)
        elif not pep8.excluded(path):
            options.counters["files"] += 1
            runner(path)

    pep8.print_statistics()
    errors = pep8.get_count("E")
    warnings = pep8.get_count("W")
    message = "pep8: %d errors / %d warnings" % (errors, warnings)
    print(message)
    assert errors + warnings == 0, message
Exemplo n.º 3
0
def test_pep8():
    arglist = [
        "--statistics",
        "--filename=*.py",
        "--show-source",
        "--repeat",
        "--exclude=SVGdraw.py",
        "--ignore=E302,E701",
        #"--show-pep8",
        #"-qq",
        #"-v",
        BASE_DIR,
    ]

    options, args = pep8.process_options(arglist)
    runner = pep8.input_file

    for path in args:
        if isdir(path):
            pep8.input_dir(path, runner=runner)
        elif not pep8.excluded(path):
            options.counters["files"] += 1
            runner(path)

    pep8.print_statistics()
    errors = pep8.get_count("E")
    warnings = pep8.get_count("W")
    message = "pep8: %d errors / %d warnings" % (errors, warnings)
    print message
    assert errors + warnings == 0, message
Exemplo n.º 4
0
def test_pep8():
    arglist = [
        "--statistics",
        "--filename=*.py",
        "--show-source",
        "--benchmark",
        "--repeat",
        "--show-pep8",
        #'--qq',
        #'-v',
        BASE_DIR,
    ]

    options, args = pep8.process_options(arglist)
    runner = pep8.input_file

    for path in args:
        if os.path.isdir(path):
            pep8.input_dir(path, runner=runner)
        elif not pep8.excluded(path):
            options.counters["files"] += 1
            runner(path)

    pep8.print_statistics()
    errors = pep8.get_count("E")
    warnings = pep8.get_count("W")
    message = "pep8: %d errors / %d warnings" % (errors, warnings)
    print message
    assert errors + warnings == 0, message
Exemplo n.º 5
0
def test_pep8():
    arglist = [
        '--statistics',
        '--filename=*.py',
        '--show-source',
        '--repeat',
        #'--show-pep8',
        #'-qq',
        #'-v',
        BASE_DIR,
    ]

    options, args = pep8.process_options(arglist)
    runner = pep8.input_file

    for path in args:
        if os.path.isdir(path):
            pep8.input_dir(path, runner=runner)
        elif not pep8.excluded(path):
            options.counters['files'] += 1
            runner(path)

    pep8.print_statistics()
    errors = pep8.get_count('E')
    warnings = pep8.get_count('W')
    message = 'pep8: %d errors / %d warnings' % (errors, warnings)
    print message
    assert errors + warnings == 0, message
Exemplo n.º 6
0
 def check_filename(self, root, filename):
     pep8.process_options(
         ["--repeat", "--select=%s" % (",".join(ERRORS),), filename]
     )
     pep8.input_file(filename)
     result = pep8.get_count()
     if result:
         raise AssertionError("ERROR: %d PEP8 errors in %s" % (result, filename,))
Exemplo n.º 7
0
 def check_filename(self, root, filename):
     pep8.process_options([
         '--repeat',
         '--select=%s' % (','.join(ERRORS), ), filename
         ])
     pep8.input_file(filename)
     result = pep8.get_count()
     if result:
         raise AssertionError("ERROR: %d PEP8 errors in %s" % (result,
                                                               filename))
Exemplo n.º 8
0
    def test_pep8(self):
        arglist = [
                '--statistics',
                '--filename=*.py',
                '--show-source',
                '--repeat',
                CURRENT_DIR,
                ]
        options, args = pep8.process_options(arglist)
        runner = pep8.input_file

        for path in args:
            if isdir(path):
                pep8.input_dir(path, runner=runner)
            elif not pep8.excluded(path):
                options.counters['files'] += 1
                runner(path)

        pep8.print_statistics()
        errors = pep8.get_count('E')
        warnings = pep8.get_count('W')
        message = 'pep8: {0} errors / {1} warnings'.format(errors, warnings)
        self.assertEqual(errors, warnings, message)
Exemplo n.º 9
0
Here are the results of the automatic PEP 8 syntax checker:

""")

# backup stdout
stdout = sys.stdout
sys.stdout = StringIO()

# clean up runner options
options, args = process_options()
options.repeat = True
input_dir(path, runner=input_file)
sys.stdout.seek(0)
data = sys.stdout.read()
statistic = get_statistics('')
count = get_count()

if count == 0:
    fh.write("The PEP 8 checker didn't find any issues.\n")
else:
    fh.write("\n")
    fh.write(".. rubric:: Statistic\n")
    fh.write("\n")
    fh.write("======= =====================================================\n")
    fh.write("Count   PEP 8 message string                                 \n")
    fh.write("======= =====================================================\n")
    for stat in statistic:
        fh.write(stat + "\n")
    fh.write("======= =====================================================\n")
    fh.write("\n")
Exemplo n.º 10
0
""")


# backup stdout
stdout = sys.stdout
sys.stdout = StringIO()

# clean up runner options
options, args = process_options()
options.repeat = True
input_dir(path, runner=input_file)
sys.stdout.seek(0)
data = sys.stdout.read()
statistic = get_statistics('')
count = get_count()

if count == 0:
    fh.write("The PEP 8 checker didn't find any issues.\n")
else:
    fh.write("\n")
    fh.write(".. rubric:: Statistic\n")
    fh.write("\n")
    fh.write("======= =====================================================\n")
    fh.write("Count   PEP 8 message string                                 \n")
    fh.write("======= =====================================================\n")
    for stat in statistic:
        fh.write(stat + "\n")
    fh.write("======= =====================================================\n")
    fh.write("\n")
Exemplo n.º 11
0
    def test_pep8():
        if pep8.__version__ >= '1.3':
            arglist = [['statistics', True],
                       ['show-source', True],
                       ['repeat', True],
                       ['exclude', []],
                       ['paths', [BASE_DIR]]]

            pep8style = pep8.StyleGuide(arglist,
                                        parse_argv=False,
                                        config_file=True)
            options = pep8style.options
            if options.doctest:
                import doctest
                fail_d, done_d = doctest.testmod(report=False,
                                                 verbose=options.verbose)
                fail_s, done_s = selftest(options)
                count_failed = fail_s + fail_d
                if not options.quiet:
                    count_passed = done_d + done_s - count_failed
                    print("%d passed and %d failed." % (count_passed,
                                                        count_failed))
                    print("Test failed." if count_failed else "Test passed.")
                if count_failed:
                    sys.exit(1)
            if options.testsuite:
                init_tests(pep8style)
            report = pep8style.check_files()
            if options.statistics:
                report.print_statistics()
            if options.benchmark:
                report.print_benchmark()
            if options.testsuite and not options.quiet:
                report.print_results()
            if report.total_errors:
                if options.count:
                    sys.stderr.write(str(report.total_errors) + '\n')
                sys.exit(1)
            # reporting errors (additional summary)
            errors = report.get_count('E')
            warnings = report.get_count('W')
            message = 'pep8: %d errors / %d warnings' % (errors, warnings)
            print(message)
            assert report.total_errors == 0, message
        else:
            # under pep8 1.3
            arglist = [
                '--statistics',
                '--filename=*.py',
                '--show-source',
                '--benchmark',
                '--repeat',
                '--show-pep8',
                #'--qq',
                #'-v',
                BASE_DIR, ]

            options, args = pep8.process_options(arglist)
            runner = pep8.input_file

            for path in args:
                if os.path.isdir(path):
                    pep8.input_dir(path, runner=runner)
                elif not pep8.excluded(path):
                    options.counters['files'] += 1
                    runner(path)

            pep8.print_statistics()
            errors = pep8.get_count('E')
            warnings = pep8.get_count('W')
            message = 'pep8: %d errors / %d warnings' % (errors, warnings)
            print(message)
            assert errors + warnings == 0, message