unittests.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:OPMLtoMM 作者: adxsoft 项目源码 文件源码
def print_diffs(expected,actual):
    a=expected
    b=actual
    s = SequenceMatcher(None,a,b)
    print '\n'
    ctr=0
    for block in s.get_matching_blocks():
        apos=block[0]
        bpos=block[0]
        aendpos=apos+block[2]
        bendpos=bpos+block[2]
        achunk=expected[apos:aendpos]
        bchunk=actual[bpos:bendpos]
        # print "a[%d] and b[%d] match for %d elements" % block
        print '\nACTUAL has matching Error at '+str(aendpos)
        print 'Expected ='+expected[bendpos:bendpos+100]+'\nFound    ='+actual[aendpos:aendpos+100]
        print 'Matched values from 0 to '+str(aendpos-1)+' are'
        print ' EXPECTED='+bchunk
        print ' ACTUAL  ='+achunk
        print ''
        if ctr==0:
            break
        else:
            ctr+=1

###########################################################################
## Unit Tests - OPML to MM conversions
###########################################################################
#
# These tests are designed to run in the local project folder opmltomm
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号