def test_pep8_conformance(self): pep8style = StyleGuide(testsuite=True, exclude=["python-yahooapi"]) report = pep8style.init_report() pep8style.input_dir(dirname=join(getcwd(), 'yfantasy')) self.assertEqual(report.total_errors, 0, "Found code style errors.")
def process_items(reporter, items, tester): """Process list of modules or packages. """ test_pylint = tester in ("pylint", "all",) test_pep8 = tester in ("pep8", "all",) if test_pep8: # PEP8 report instance setup pep8style = StyleGuide(parse_argv=False, config_file=False) if reporter.name == "csv": pep8style.options.report = CsvPep8Report(pep8style.options, reporter.writer) else: colorized = (reporter.name == "colorized") pep8style.options.report = Pep8Report(pep8style.options, reporter.line_format, reporter.out, colorized) pylint_rc_path = os.path.join(_CURRENT_PATH, "pylint.rc") for item in items: path = os.path.join(_BASE_PATH, item) if test_pylint: # Pylint tests lint.Run([path, "--rcfile={0}".format(pylint_rc_path)], reporter=reporter, exit=False) if test_pep8: # Pep8 tests if item.endswith(".py"): pep8style.input_file(path) else: pep8style.input_dir(path)
def test_pep8_conformance(self): pep8style = StyleGuide(testsuite=True) report = pep8style.init_report() pep8style.input_dir(dirname=join(getcwd(), 'accio')) self.assertEqual(report.total_errors, 0, "Found code style errors.")
def test_pep8_conformance(): """Test source code for PEP8 conformance.""" pep8style = StyleGuide(max_line_length=100) report = pep8style.options.report report.start() base_path = os.path.join(os.path.dirname(__file__), '..') pep8style.input_dir(os.path.join(base_path, 'ros_buildfarm')) pep8style.input_dir(os.path.join(base_path, 'scripts')) report.stop() assert report.total_errors == 0, \ 'Found %d code style errors (and warnings)' % report.total_errors
def test_pep8style(self): test_dir = os.path.dirname(os.path.abspath(__file__)) dist_dir = os.path.dirname(test_dir) pep8style = StyleGuide() saved_stdout, sys.stdout = sys.stdout, io.StringIO() try: pep8style.input_dir(dist_dir) output = sys.stdout.getvalue() finally: sys.stdout = saved_stdout report = pep8style.check_files() newline = os.linesep result_format = 'PEP8 failed (errors={:d}, warnings={:d})' + newline result = result_format.format(report.get_count('E'), report.get_count('W')) statistics = newline.join(report.get_statistics()) + newline message = newline.join((result, statistics, output)) self.assertEqual(report.get_count(), 0, message)
def process_items(reporter, items, tester): """Process list of modules or packages. """ test_pylint = tester in ( "pylint", "all", ) test_pep8 = tester in ( "pep8", "all", ) if test_pep8: # PEP8 report instance setup pep8style = StyleGuide(parse_argv=False, config_file=False) if reporter.name == "csv": pep8style.options.report = CsvPep8Report(pep8style.options, reporter.writer) else: colorized = (reporter.name == "colorized") pep8style.options.report = Pep8Report(pep8style.options, reporter.line_format, reporter.out, colorized) pylint_rc_path = os.path.join(_CURRENT_PATH, "pylint.rc") for item in items: path = os.path.join(_BASE_PATH, item) if test_pylint: # Pylint tests lint.Run([path, "--rcfile={0}".format(pylint_rc_path)], reporter=reporter, exit=False) if test_pep8: # Pep8 tests if item.endswith(".py"): pep8style.input_file(path) else: pep8style.input_dir(path)
execution_time = time.time() - start print("Execution time was {0} seconds.\n".format(execution_time)) # We're using RMSE as a metric. error = math.sqrt( mean_squared_error(predictions, prediction_df[settings.PREDICTION_COLUMN])) print("Found root mean squared error of: {0}\n".format(error)) # Setup a buffer to capture pep8 output. buffer = StringIO.StringIO() sys.stdout = buffer # Initialize and run a pep8 style checker. pep8style = StyleGuide(ignore="E121,E123,E126,E226,E24,E704,E501") pep8style.input_dir(settings.BASE_DIR) report = pep8style.check_files() # Change stdout back to the original version. sys.stdout = sys.__stdout__ pep8_results = buffer.getvalue() if report.total_errors > 0: print("Pep8 violations found! They are shown below.") print("----------------------") print(pep8_results) # Write all the results to a file if needed. if args.write: write_data = { "error": error,
def pep8(self): from pep8 import StyleGuide sg = StyleGuide() sg.input_dir('aragog') sg.input_dir('test')