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

Method test_one_insert_homogenous_sequence

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

Source from the content-addressed store, hash-verified

56class TestAutojunk(unittest.TestCase):
57 """Tests for the autojunk parameter added in 2.7"""
58 def test_one_insert_homogenous_sequence(self):
59 # By default autojunk=True and the heuristic kicks in for a sequence
60 # of length 200+
61 seq1 = 'b' * 200
62 seq2 = 'a' + 'b' * 200
63
64 sm = difflib.SequenceMatcher(None, seq1, seq2)
65 self.assertAlmostEqual(sm.ratio(), 0, places=3)
66 self.assertEqual(sm.bpopular, {'b'})
67
68 # Now turn the heuristic off
69 sm = difflib.SequenceMatcher(None, seq1, seq2, autojunk=False)
70 self.assertAlmostEqual(sm.ratio(), 0.9975, places=3)
71 self.assertEqual(sm.bpopular, set())
72
73
74class TestSFbugs(unittest.TestCase):

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected