def fetch_checks(cfg): base = [ checks.CheckValidity(cfg), checks.CheckTrailingWhitespace(cfg), checks.CheckIndentationNoTab(cfg), checks.CheckCarriageReturn(cfg), checks.CheckMaxLineLength(cfg), checks.CheckNewlineEndOfFile(cfg), ] mgr = extension.ExtensionManager( namespace="doc8.extension.check", invoke_on_load=True, invoke_args=(cfg.copy(),) ) addons = [] for e in mgr: addons.append(e.obj) return base + addons
def test_newline(self): tests = [ (1, b"testing"), (1, b"testing\ntesting"), (0, b"testing\n"), (0, b"testing\ntesting\n"), ] for expected_errors, line in tests: with tempfile.NamedTemporaryFile() as fh: fh.write(line) fh.flush() parsed_file = parser.ParsedFile(fh.name) check = checks.CheckNewlineEndOfFile({}) errors = list(check.report_iter(parsed_file)) self.assertEqual(expected_errors, len(errors))