Skip to content

Commit ef3e633

Browse files
tests/: avoid running known very slow tests if PYMUPDF_TEST_QUICK=1.
1 parent 6aeb659 commit ef3e633

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

tests/test_memory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pymupdf
2+
import util
23

34
import gc
45
import os
@@ -17,6 +18,8 @@ def test_2791():
1718
'''
1819
Check for memory leaks.
1920
'''
21+
if util.skip_slow_tests('test_2791'):
22+
return
2023
if os.environ.get('PYODIDE_ROOT'):
2124
print('test_2791(): not running on Pyodide - No module named \'psutil\'.')
2225
return

tests/test_pixmap.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import pytest
1919
import textwrap
2020
import time
21+
import util
2122

2223

2324
scriptdir = os.path.abspath(os.path.dirname(__file__))
@@ -371,6 +372,8 @@ def do(gi):
371372

372373

373374
def test_3848():
375+
if util.skip_slow_tests('test_3848'):
376+
return
374377
if os.environ.get('PYMUPDF_RUNNING_ON_VALGRIND') == '1':
375378
# Takes 40m on Github.
376379
print(f'test_3848(): not running on valgrind because very slow.', flush=1)
@@ -509,6 +512,9 @@ def test_4336():
509512

510513

511514
def test_4435():
515+
# This is slow, e.g. 224s.
516+
if util.skip_slow_tests('test_4435'):
517+
return
512518
print(f'{pymupdf.version=}')
513519
path = os.path.normpath(f'{__file__}/../../tests/resources/test_4435.pdf')
514520
with pymupdf.open(path) as document:

tests/util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ def download(url, name, size=None):
2626
with open(path, 'wb') as f:
2727
f.write(r.content)
2828
return path
29+
30+
def skip_slow_tests(test_name):
31+
PYMUPDF_TEST_QUICK = os.environ.get('PYMUPDF_TEST_QUICK')
32+
if PYMUPDF_TEST_QUICK == '1':
33+
print(f'{test_name}(): skipping test because {PYMUPDF_TEST_QUICK=}.')
34+
return True

0 commit comments

Comments
 (0)