コード例 #1
0
    def test_pycodestyle(self):

        # NOTE(jecarey): Add tests marked as off_by_default to enable testing
        turn_on = set(['H106'])
        if self.options.select:
            turn_on.update(self.options.select)
        self.options.select = tuple(turn_on)
        self.options.ignore = ('N530', )

        report = pycodestyle.BaseReport(self.options)
        checker = pycodestyle.Checker(filename=self.filename,
                                      lines=self.lines,
                                      options=self.options,
                                      report=report)
        checker.check_all()
        self.addDetail('doctest', content.text_content(self.raw))
        if self.code == 'Okay':
            self.assertThat(
                len(report.counters),
                matchers.Not(
                    matchers.GreaterThan(len(self.options.benchmark_keys))),
                "incorrectly found %s" % ', '.join([
                    key for key in report.counters
                    if key not in self.options.benchmark_keys
                ]))
        else:
            self.addDetail(
                'reason',
                content.text_content("Failed to trigger rule %s" % self.code))
            self.assertIn(self.code, report.counters)
コード例 #2
0
ファイル: test_local.py プロジェクト: vasharma1/hacking
 def test_local_check(self):
     flake8_style = engine.get_style_guide(parse_argv=False, ignore='F')
     report = pycodestyle.BaseReport(flake8_style.options)
     line = ["#this-is-the-test-phrase"]
     checker = pycodestyle.Checker(lines=line, options=flake8_style.options,
                                   report=report)
     checker.check_all()
     self.assertIn("L100", report.counters)
コード例 #3
0
ファイル: test_app.py プロジェクト: magenta-af/os2datascanner
 def do_test(self):
     # print "PATH:", filepath
     # arglist = ['--exclude=lib,migrations', filepath]
     pep8styleguide = pycodestyle.StyleGuide(
         exclude=['lib', 'migrations'],
         filename=['*.py'],
         filepath=filepath,
         show_pep8=False,
         show_source=False,
     )
     pep8styleguide.input_dir(filepath)
     basereport = pycodestyle.BaseReport(benchmark_keys={})
     output = basereport.get_statistics(prefix='')
     # print "PEP8 OUTPUT: " + str(output)
     self.assertEqual(len(output), 0)
コード例 #4
0
import bs4
import pycodestyle

assert bs4.__version__ == "4.9.1", "beautifulsoup version incorrect."
assert pycodestyle.__version__ == "2.6.0", "pycodestyle version incorrect."

# Check the coding style without any output
report = pycodestyle.BaseReport(options=pycodestyle.StyleGuide().options)
pycodestyle.Checker(filename=bs4.__file__, report=report).check_all()
statistics = sorted(report.get_statistics())

print("".join(statistics[row][column] for row, column in [
    (2, 39),
    (3, 13),
    (4, 22),
    (5, 36),
    (6, 39),
    (7, 17),
    (6, 21),
    (7, 35),
    (8, 14),
    (9, 22),
    (10, 20),
]))