def test_cr(self): lines = ["\tabc", "efg", "\r\n"] check = checks.CheckCarriageReturn({}) errors = [] for line in lines: errors.extend(check.report_iter(line)) self.assertEqual(1, len(errors)) (code, msg) = errors[0] self.assertIn(code, check.REPORTS)
def test_cr(self): content = b"Windows line ending\r\nLegacy Mac line ending\r" content += (b"a" * 79) + b"\r\n" + b"\r" conf = {"max_line_length": 79} with tempfile.NamedTemporaryFile() as fh: fh.write(content) fh.flush() parsed_file = parser.ParsedFile(fh.name) check = checks.CheckCarriageReturn(conf) errors = list(check.report_iter(parsed_file)) self.assertEqual(4, len(errors)) (line, code, msg) = errors[0] self.assertIn(code, check.REPORTS)
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