Back to index

python3.2  3.2.2
Public Member Functions
test.test_difflib.TestWithAscii Class Reference

List of all members.

Public Member Functions

def test_one_insert
def test_one_delete
def test_bjunk

Detailed Description

Definition at line 8 of file test_difflib.py.


Member Function Documentation

Definition at line 32 of file test_difflib.py.

00032 
00033     def test_bjunk(self):
00034         sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ',
00035                 a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40)
00036         self.assertEqual(sm.bjunk, set())
00037 
00038         sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ',
00039                 a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40 + ' ' * 20)
00040         self.assertEqual(sm.bjunk, {' '})
00041 
00042         sm = difflib.SequenceMatcher(isjunk=lambda x: x in [' ', 'b'],
00043                 a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40 + ' ' * 20)
00044         self.assertEqual(sm.bjunk, {' ', 'b'})
00045 

Here is the call graph for this function:

Definition at line 24 of file test_difflib.py.

00024 
00025     def test_one_delete(self):
00026         sm = difflib.SequenceMatcher(None, 'a' * 40 + 'c' + 'b' * 40, 'a' * 40 + 'b' * 40)
00027         self.assertAlmostEqual(sm.ratio(), 0.994, places=3)
00028         self.assertEqual(list(sm.get_opcodes()),
00029             [   ('equal', 0, 40, 0, 40),
00030                 ('delete', 40, 41, 40, 40),
00031                 ('equal', 41, 81, 40, 80)])

Here is the call graph for this function:

Definition at line 9 of file test_difflib.py.

00009 
00010     def test_one_insert(self):
00011         sm = difflib.SequenceMatcher(None, 'b' * 100, 'a' + 'b' * 100)
00012         self.assertAlmostEqual(sm.ratio(), 0.995, places=3)
00013         self.assertEqual(list(sm.get_opcodes()),
00014             [   ('insert', 0, 0, 0, 1),
00015                 ('equal', 0, 100, 1, 101)])
00016         self.assertEqual(sm.bpopular, set())
00017         sm = difflib.SequenceMatcher(None, 'b' * 100, 'b' * 50 + 'a' + 'b' * 50)
00018         self.assertAlmostEqual(sm.ratio(), 0.995, places=3)
00019         self.assertEqual(list(sm.get_opcodes()),
00020             [   ('equal', 0, 50, 0, 50),
00021                 ('insert', 50, 50, 50, 51),
00022                 ('equal', 50, 100, 51, 101)])
00023         self.assertEqual(sm.bpopular, set())

Here is the call graph for this function:


The documentation for this class was generated from the following file: