MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_4336

Function test_4336

tests/test_pixmap.py:459–503  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

457
458
459def test_4336():
460 if 0:
461 # Compare with last classic release.
462 import pickle
463 path_out = os.path.normpath(f'{__file__}/../../tests/resources/test_4336_cc')
464 code = textwrap.dedent(f'''
465 import fitz
466 import os
467 import time
468 import pickle
469
470 path = os.path.normpath(f'{__file__}/../../tests/resources/nur-ruhig.jpg')
471 pixmap = fitz.Pixmap(path)
472 t = time.time()
473 for i in range(10):
474 cc = pixmap.color_count()
475 t = time.time() - t
476 print(f'test_4336(): {{t=}}')
477 with open({path_out!r}, 'wb') as f:
478 pickle.dump(cc, f)
479 ''')
480 path_code = os.path.normpath(f'{__file__}/../../tests/resources/test_4336.py')
481 with open(path_code, 'w') as f:
482 f.write(code)
483 venv = os.path.normpath(f'{__file__}/../../tests/resources/test_4336_venv')
484 command = f'{sys.executable} -m venv {venv}'
485 command += f' && . {venv}/bin/activate'
486 command += f' && pip install --force-reinstall pymupdf==1.23.8'
487 command += f' && python {path_code}'
488 print(f'Running: {command}', flush=1)
489 subprocess.run(command, shell=1, check=1)
490 with open(path_out, 'rb') as f:
491 cc_old = pickle.load(f)
492 else:
493 cc_old = None
494 path = os.path.normpath(f'{__file__}/../../tests/resources/nur-ruhig.jpg')
495 pixmap = pymupdf.Pixmap(path)
496 t = time.time()
497 for i in range(10):
498 cc = pixmap.color_count()
499 t = time.time() - t
500 print(f'test_4336(): {t=}')
501
502 if cc_old:
503 assert cc == cc_old
504
505
506def test_4435():

Callers

nothing calls this directly

Calls 3

color_countMethod · 0.95
writeMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…