@@ -1518,7 +1518,7 @@ def dict_set_path(dict_, *items):
15181518 results = dict ()
15191519
15201520 for path in paths :
1521- print (path )
1521+ print (f' { path = } ' )
15221522 for ext in extensions :
15231523 path2 = f'{ root } /foo{ ext } '
15241524 path3 = shutil .copy2 (f'{ root } /{ path } ' , path2 )
@@ -1548,7 +1548,7 @@ def dict_set_path(dict_, *items):
15481548 e = ee
15491549 wt = pymupdf .TOOLS .mupdf_warnings ()
15501550 text = get_result (e , document )
1551- print (f' fz_open_document_with_stream(magic={ ext !r} ) => { text } ' )
1551+ print (f' fz_open_document_with_stream() { path = } magic={ ext !r} ) => { text } ' )
15521552 dict_set_path (results , path , ext , 'stream' , text )
15531553
15541554 finally :
@@ -1591,16 +1591,31 @@ def dict_set_path(dict_, *items):
15911591 with open (path_out , 'w' ) as f :
15921592 json .dump (results , f , indent = 4 , sort_keys = 1 )
15931593
1594- with open (os .path .normpath (f'{ __file__ } /../../tests/resources/test_open2_expected.json' )) as f :
1594+ path_expected = os .path .normpath (f'{ __file__ } /../../tests/resources/test_open2_expected.json' )
1595+ with open (path_expected ) as f :
15951596 results_expected = json .load (f )
15961597 if results != results_expected :
15971598 print (f'results != results_expected:' )
1598- def show (r , name ):
1599- text = json .dumps (r , indent = 4 , sort_keys = 1 )
1600- print (f'{ name } :' )
1601- print (textwrap .indent (text , ' ' ))
1602- show (results_expected , 'results_expected' )
1603- show (results , 'results' )
1599+ print (f'Expected: { path_expected } ' )
1600+ print (f'Actual: { path_out } ' )
1601+ if 0 :
1602+ # Show entire json data. Very verbose.
1603+ def show (r , name ):
1604+ text = json .dumps (r , indent = 4 , sort_keys = 1 )
1605+ print (f'{ name } :' )
1606+ print (textwrap .indent (text , ' ' ))
1607+ show (results_expected , 'results_expected' )
1608+ show (results , 'results' )
1609+ json_expected = json .dumps (results_expected , indent = 4 , sort_keys = 1 )
1610+ json_actual = json .dumps (results , indent = 4 , sort_keys = 1 )
1611+ import difflib
1612+ diff = difflib .unified_diff (
1613+ json_expected .split ('\n ' ),
1614+ json_actual .split ('\n ' ),
1615+ lineterm = '' ,
1616+ )
1617+ print (f'Diff expected => actual:' )
1618+ print (textwrap .indent ('\n ' .join (diff ), ' ' ))
16041619 assert 0
16051620
16061621
0 commit comments