def test_pep8(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) report = pep8.BaseReport(self.options) checker = pep8.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)
def test_local_check(self): flake8_style = engine.get_style_guide(parse_argv=False, ignore='F') report = pep8.BaseReport(flake8_style.options) line = ["#this-is-the-test-phrase"] checker = pep8.Checker(lines=line, options=flake8_style.options, report=report) checker.check_all() self.assertIn("L100", report.counters)
def do_test(self): # print "PATH:", filepath # arglist = ['--exclude=lib,migrations', filepath] pep8styleguide = pep8.StyleGuide( exclude=['lib', 'migrations'], filename=['*.py'], filepath=filepath, show_pep8=False, show_source=False, ) pep8styleguide.input_dir(filepath) basereport = pep8.BaseReport(benchmark_keys={}) output = basereport.get_statistics(prefix='') # print "PEP8 OUTPUT: " + str(output) self.assertEqual(len(output), 0)
def test_pep8(self): report = pep8.BaseReport(self.options) checker = pep8.Checker(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)