summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-06-21 18:57:36 (GMT)
committerRaymond Hettinger <python@rcn.com>2014-06-21 18:57:36 (GMT)
commitfabefc3c5b9e174e4eef2cb351a6ed8c81d721b0 (patch)
treef7b6e74a14c8feef6c67dbc7ff6b51616eb0d712 /Lib/test
parent8aa9e4268fae4646b40d230962d74a6b61397217 (diff)
downloadcpython-fabefc3c5b9e174e4eef2cb351a6ed8c81d721b0.zip
cpython-fabefc3c5b9e174e4eef2cb351a6ed8c81d721b0.tar.gz
cpython-fabefc3c5b9e174e4eef2cb351a6ed8c81d721b0.tar.bz2
Issue 21635: Fix caching in difflib.SequenceMatcher.get_matching_blocks().
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_difflib.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py
index 325449a..0ba8f0e 100644
--- a/Lib/test/test_difflib.py
+++ b/Lib/test/test_difflib.py
@@ -76,6 +76,15 @@ class TestSFbugs(unittest.TestCase):
diff_gen = difflib.unified_diff([], [])
self.assertRaises(StopIteration, next, diff_gen)
+ def test_matching_blocks_cache(self):
+ # Issue #21635
+ s = difflib.SequenceMatcher(None, "abxcd", "abcd")
+ first = s.get_matching_blocks()
+ second = s.get_matching_blocks()
+ self.assertEqual(second[0].size, 2)
+ self.assertEqual(second[1].size, 2)
+ self.assertEqual(second[2].size, 0)
+
def test_added_tab_hint(self):
# Check fix for bug #1488943
diff = list(difflib.Differ().compare(["\tI am a buggy"],["\t\tI am a bug"]))