File: mergeall-products/unzipped/test/test-normalization-3.3/SameVersus3.2/_TEST.py

#--------------------------------------------------------------
# [3.3] Ensure that 3.3's results are the same as 3.2's, sans 
# any Unicode-variant diffs.  Run this script in its folder.
# It assumes a Unix shell, and runs both mergeall and diffall 
# over a large but private content collection; edit settings
# to test your content.  Logs have been trimmed for privacy,
# and rerun to discount a no-cache penalty for the first test.
#--------------------------------------------------------------

import os
cmd = os.system

# edit me
code = '/Users/me/MY-STUFF/Code'
mergeall32 = '../../Mergeall-source'    # edit me: 3.2 unzip
mergeall33 = code + '/mergeall'         # edit me: 3.3 production

# edit me
content = '~/MY-STUFF'


# mergeall same?
cmd('python3 %s/mergeall.py '
         '%s %s -report -skipcruft > mergeall-32.txt' % (mergeall32, content, content))

cmd('python3 %s/mergeall.py '
         '%s %s -report -skipcruft > mergeall-33.txt' % (mergeall33, content, content))

cmd('diff mergeall-32.txt mergeall-33.txt > mergeall-32-33-diffs.txt')


# diffall same?
cmd('python3 %s/diffall.py '
         '%s %s -skipcruft > diffall-32.txt' % (mergeall32, content, content))

cmd('python3 %s/diffall.py '
         '%s %s -skipcruft > diffall-33.txt' % (mergeall33, content, content))

cmd('diff diffall-32.txt diffall-33.txt > diffall-32-33-diffs.txt')


#------------------------------------------------------------
# Results:
# - normalization messages okay: 
#     new in 3.3
# - diffall message diffs okay (below):
#     3.2 prints NFD (decomposed, on macos)
#     3.3 prints normalized NFC (composed, via normalization)
# - all else same, and runtimes unchanged
#------------------------------------------------------------

"""
>>> msg32 = '< pymailgui-spÄÄÄm.png matches'
>>> msg33 = '> pymailgui-spÄÄÄm.png matches'
>>> 
>>> len(msg32), len(msg33)
(33, 30)
>>> 
>>> msg32.encode('utf8')
b'< pymailgui-spA\xcc\x88A\xcc\x88A\xcc\x88m.png matches'
>>> msg33.encode('utf8')
b'> pymailgui-sp\xc3\x84\xc3\x84\xc3\x84m.png matches'
"""



[Home page] Books Code Blog Python Author Train Find ©M.Lutz