def assert_similar_pages(first, second, ratio=0.9, msg=None):
 lines_a = set([l.strip() for l in first.split('\n')])
 lines_b = set([l.strip() for l in second.split('\n')])
 common = lines_a.intersection(lines_b)
 similarity = ((1.0 * len(common)) / max(len(lines_a), len(lines_b)))
 nose.tools.assert_true((similarity >= ratio), msg)

def assert_similar_pages ( first , second , ratio = 0.9 , msg = None ) : lines_a = set ( [ l . strip ( ) for l in first . split ( '\n' ) ] ) lines_b = set ( [ l . strip ( ) for l in second . split ( '\n' ) ] ) common = lines_a . intersection ( lines_b ) similarity = ( ( 1.0 * len ( common ) ) / max ( len ( lines_a ) , len ( lines_b ) ) ) nose . tools . assert_true ( ( similarity >= ratio ) , msg )
asserts that most of the lines in the two pages are identical .