| 330 | gi_pythonpath = os.path.abspath(f'{gi}/../..') |
| 331 | |
| 332 | def do(gi): |
| 333 | # Run code that will import gi and pymupdf in different orders, and |
| 334 | # return contents of generated .png file as a bytes. |
| 335 | out = f'{root}/tests/resources/test_3493_{gi}.png' |
| 336 | run_code( |
| 337 | f''' |
| 338 | if {gi}==0: |
| 339 | import pymupdf |
| 340 | elif {gi}==1: |
| 341 | from gi.repository import GdkPixbuf |
| 342 | import pymupdf |
| 343 | elif {gi}==2: |
| 344 | import pymupdf |
| 345 | from gi.repository import GdkPixbuf |
| 346 | else: |
| 347 | assert 0 |
| 348 | document = pymupdf.Document('{in_path}') |
| 349 | page = document[0] |
| 350 | print(f'{gi=}: saving to: {out}') |
| 351 | page.get_pixmap().save('{out}') |
| 352 | ''' |
| 353 | , |
| 354 | os.path.abspath(f'{root}/tests/resources/test_3493_{gi}.py'), |
| 355 | pythonpath=gi_pythonpath, |
| 356 | ) |
| 357 | with open(out, 'rb') as f: |
| 358 | return f.read() |
| 359 | |
| 360 | out0 = do(0) |
| 361 | out1 = do(1) |