diff --git a/tests/test_diff.py b/tests/test_diff.py index 7433e7e..ab5e2d0 100644 --- a/tests/test_diff.py +++ b/tests/test_diff.py @@ -640,7 +640,6 @@ def test_with_xmlid(self): ) def test_change_attribs(self): - left = """
diff --git a/tests/test_formatting.py b/tests/test_formatting.py index a63cd17..9ae8edf 100644 --- a/tests/test_formatting.py +++ b/tests/test_formatting.py @@ -327,8 +327,8 @@ def test_replace_text_in(self): left = "This is a bit of text, right" + END action = actions.UpdateTextIn("/document/node", "Also a bit of text, rick") expected = ( - START + ">Also" - " a bit of text, rick" + START + '>Also' + ' a bit of text, rick' "" + END ) @@ -345,8 +345,8 @@ def test_replace_text_after_2(self): left = "This is a bit of text, right" action = actions.UpdateTextAfter("/document/node", "Also a bit of text, rick") expected = ( - START + "/>Also" - " a bit of text, rick" + START + '/>Also' + ' a bit of text, rick' "" ) @@ -356,12 +356,13 @@ def test_replace_complete_text(self): left = "aaaaaaa bbbbbb" action = actions.UpdateTextIn("/document/node", "ccccc dddd eee") expected = ( - START + ">ccccc dddd eee" + START + '>ccccc dddd eee' "" + END ) self._format_test(left, action, expected, use_replace=True) + class DiffFormatTests(unittest.TestCase): def _format_test(self, action, expected): formatter = formatting.DiffFormatter() @@ -559,7 +560,6 @@ def test_all_actions(self): class FormatterFileTests(unittest.TestCase): - formatter = None # Override this maxDiff = None @@ -568,7 +568,6 @@ def process(self, left, right): class XMLFormatterFileTests(FormatterFileTests): - # The XMLFormatter has no text or formatting tags, so formatter = formatting.XMLFormatter( pretty_print=False, normalize=formatting.WS_TEXT @@ -579,7 +578,6 @@ class XMLFormatterFileTests(FormatterFileTests): class HTMLFormatterFileTests(FormatterFileTests): - # We use a few tags for the placeholder tests. #
is intentionally left out, to test an edge case # with empty non-formatting tags in text. diff --git a/tests/test_patch.py b/tests/test_patch.py index 62ff76e..702c1fe 100644 --- a/tests/test_patch.py +++ b/tests/test_patch.py @@ -23,7 +23,6 @@ class PatcherTests(unittest.TestCase): - patcher = Patcher() def _test(self, start, action, end): diff --git a/tests/test_utils.py b/tests/test_utils.py index d8f60a5..1089f8a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -111,7 +111,6 @@ def _diff(self, left, right, result): self.assertEqual("".join(res), result) def test_lcs(self): - self._diff("ABCDEF", "ABCDEF", "ABCDEF") self._diff("ABCDEF", "GHIJKL", "") diff --git a/xmldiff/diff_match_patch.py b/xmldiff/diff_match_patch.py index 40487f5..bfe59e7 100644 --- a/xmldiff/diff_match_patch.py +++ b/xmldiff/diff_match_patch.py @@ -1136,7 +1136,7 @@ def diff_prettyHtml(self, diffs): HTML representation. """ html = [] - for (op, data) in diffs: + for op, data in diffs: text = ( data.replace("&", "&") .replace("<", "<") @@ -1161,7 +1161,7 @@ def diff_text1(self, diffs): Source text. """ text = [] - for (op, data) in diffs: + for op, data in diffs: if op != self.DIFF_INSERT: text.append(data) return "".join(text) @@ -1176,7 +1176,7 @@ def diff_text2(self, diffs): Destination text. """ text = [] - for (op, data) in diffs: + for op, data in diffs: if op != self.DIFF_DELETE: text.append(data) return "".join(text) @@ -1194,7 +1194,7 @@ def diff_levenshtein(self, diffs): levenshtein = 0 insertions = 0 deletions = 0 - for (op, data) in diffs: + for op, data in diffs: if op == self.DIFF_INSERT: insertions += len(data) elif op == self.DIFF_DELETE: @@ -1220,7 +1220,7 @@ def diff_toDelta(self, diffs): Delta text. """ text = [] - for (op, data) in diffs: + for op, data in diffs: if op == self.DIFF_INSERT: # High ascii will raise UnicodeDecodeError. Use Unicode instead. data = data.encode("utf-8") @@ -1708,7 +1708,7 @@ def patch_apply(self, patches, text): else: self.diff_cleanupSemanticLossless(diffs) index1 = 0 - for (op, data) in patch.diffs: + for op, data in patch.diffs: if op != self.DIFF_EQUAL: index2 = self.diff_xIndex(diffs, index1) if op == self.DIFF_INSERT: # Insertion @@ -2007,7 +2007,7 @@ def __str__(self): coords2 = str(self.start2 + 1) + "," + str(self.length2) text = ["@@ -", coords1, " +", coords2, " @@\n"] # Escape the body of the patch with %xx notation. - for (op, data) in self.diffs: + for op, data in self.diffs: if op == diff_match_patch.DIFF_INSERT: text.append("+") elif op == diff_match_patch.DIFF_DELETE: diff --git a/xmldiff/formatting.py b/xmldiff/formatting.py index e59a6f6..640ec15 100644 --- a/xmldiff/formatting.py +++ b/xmldiff/formatting.py @@ -317,7 +317,12 @@ class XMLFormatter(BaseFormatter): """ def __init__( - self, normalize=WS_NONE, pretty_print=True, text_tags=(), formatting_tags=(), use_replace=False + self, + normalize=WS_NONE, + pretty_print=True, + text_tags=(), + formatting_tags=(), + use_replace=False, ): # Mapping from placeholders -> structural content and vice versa. self.normalize = normalize @@ -593,20 +598,26 @@ def _stack_pop(): def _join_delete_insert(self, diffs): new_diffs = [] skip_next = False - for i in range(len(diffs)-1): + for i in range(len(diffs) - 1): if skip_next: skip_next = False continue op, text = diffs[i] - next_op, next_text = diffs[i+1] + next_op, next_text = diffs[i + 1] # insert, then delete - if op==diff_match_patch.DIFF_INSERT and next_op==diff_match_patch.DIFF_DELETE: + if ( + op == diff_match_patch.DIFF_INSERT + and next_op == diff_match_patch.DIFF_DELETE + ): new_diffs.append((diff_match_patch.DIFF_REPLACE, text, next_text)) - skip_next = True # also skip upcoming delete + skip_next = True # also skip upcoming delete # delete, then insert - elif next_op==diff_match_patch.DIFF_INSERT and op==diff_match_patch.DIFF_DELETE: + elif ( + next_op == diff_match_patch.DIFF_INSERT + and op == diff_match_patch.DIFF_DELETE + ): new_diffs.append((diff_match_patch.DIFF_REPLACE, next_text, text)) - skip_next = True # also skip upcoming insert + skip_next = True # also skip upcoming insert else: new_diffs.append(diffs[i]) # append last diff, if it shouldn't be skipped diff --git a/xmldiff/utils.py b/xmldiff/utils.py index 1b8f943..354f5e3 100644 --- a/xmldiff/utils.py +++ b/xmldiff/utils.py @@ -37,7 +37,6 @@ def breadth_first_traverse(node): # It also skips any items that are equal in the beginning and end, speeding # up the search, and using even less memory. def longest_common_subsequence(left_sequence, right_sequence, eqfn=eq): - start = 0 lend = lslen = len(left_sequence) rend = rslen = len(right_sequence)