MCPcopy Index your code
hub / github.com/python/cpython / test_one_insert

Method test_one_insert

Lib/test/test_difflib.py:9–22  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7
8class TestWithAscii(unittest.TestCase):
9 def test_one_insert(self):
10 sm = difflib.SequenceMatcher(None, 'b' * 100, 'a' + 'b' * 100)
11 self.assertAlmostEqual(sm.ratio(), 0.995, places=3)
12 self.assertEqual(list(sm.get_opcodes()),
13 [ ('insert', 0, 0, 0, 1),
14 ('equal', 0, 100, 1, 101)])
15 self.assertEqual(sm.bpopular, set())
16 sm = difflib.SequenceMatcher(None, 'b' * 100, 'b' * 50 + 'a' + 'b' * 50)
17 self.assertAlmostEqual(sm.ratio(), 0.995, places=3)
18 self.assertEqual(list(sm.get_opcodes()),
19 [ ('equal', 0, 50, 0, 50),
20 ('insert', 50, 50, 50, 51),
21 ('equal', 50, 100, 51, 101)])
22 self.assertEqual(sm.bpopular, set())
23
24 def test_one_delete(self):
25 sm = difflib.SequenceMatcher(None, 'a' * 40 + 'c' + 'b' * 40, 'a' * 40 + 'b' * 40)

Callers

nothing calls this directly

Calls 6

ratioMethod · 0.95
get_opcodesMethod · 0.95
listClass · 0.85
setFunction · 0.85
assertAlmostEqualMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected