Skip to content

Commit 0fd9594

Browse files
scripts/test.py: make pytest less verbose by default.
Also allow `-t` to specify multiple tests to run.
1 parent a917c84 commit 0fd9594

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

scripts/test.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,14 @@
5858
PYMUPDF_SETUP_MUPDF_BUILD, which is used by PyMuPDF/setup.py. If not
5959
specifed PyMuPDF will download its default mupdf .tgz.]
6060
-p <pytest-options>
61-
Set pytest options; default is '-s'.
62-
-t <name>
63-
Pytest test name. Should be relative to PyMuPDF directory. For example:
61+
Set pytest options; default is ''.
62+
-t <names>
63+
Pytest test names, comma-separated. Should be relative to PyMuPDF
64+
directory. For example:
6465
-t tests/test_general.py
65-
-t tests/test_general.py::test_subset_fonts
66+
-t tests/test_general.py::test_subset_fonts.
67+
To specify multiple tests, use comma-separated list and/or multiple `-t
68+
<names>` args.
6669
-v
6770
Avoid delay if venv directory already exists. We assume the existing
6871
directory was created by us earlier and is a valid venv containing all
@@ -118,7 +121,7 @@ def main(argv):
118121
build_type = None
119122
gdb = False
120123
implementations = None
121-
test_name = None
124+
test_names = list()
122125
venv_quick = False
123126
pytest_options = None
124127
timeout = None
@@ -156,7 +159,7 @@ def main(argv):
156159
elif arg == '-p':
157160
pytest_options = next(args)
158161
elif arg == '-t':
159-
test_name = next(args)
162+
test_names += next(args).split(',')
160163
elif arg == '--timeout':
161164
timeout = float(next(args))
162165
elif arg == '-v':
@@ -201,7 +204,7 @@ def do_test():
201204
implementations=implementations,
202205
valgrind=valgrind,
203206
venv_quick=venv_quick,
204-
test_name=test_name,
207+
test_names=test_names,
205208
pytest_options=pytest_options,
206209
timeout=timeout,
207210
gdb=gdb,
@@ -326,7 +329,7 @@ def test(
326329
implementations,
327330
valgrind,
328331
venv_quick=False,
329-
test_name=None,
332+
test_names=None,
330333
pytest_options=None,
331334
timeout=None,
332335
gdb=False,
@@ -339,7 +342,7 @@ def test(
339342
See top-level option `--valgrind`.
340343
venv_quick:
341344
See top-level option `-v`.
342-
test_name:
345+
test_names:
343346
See top-level option `-t`.
344347
pytest_options:
345348
See top-level option `-p`.
@@ -351,10 +354,13 @@ def test(
351354
if valgrind:
352355
pytest_options = '-s -vv'
353356
else:
354-
pytest_options = '-s'
355-
pytest_arg = pymupdf_dir_rel
356-
if test_name:
357-
pytest_arg += f'/{test_name}'
357+
pytest_options = ''
358+
pytest_arg = ''
359+
if test_names:
360+
for test_name in test_names:
361+
pytest_arg += f' {pymupdf_dir_rel}/{test_name}'
362+
else:
363+
pytest_arg += f' {pymupdf_dir_rel}'
358364
python = gh_release.relpath(sys.executable)
359365
log('Running tests with tests/run_compound.py and pytest.')
360366
try:
@@ -378,7 +384,7 @@ def test(
378384
command = (
379385
f'{python} {pymupdf_dir_rel}/tests/run_compound.py{run_compound_args}'
380386
f' valgrind --suppressions={pymupdf_dir_rel}/valgrind.supp --error-exitcode=100 --errors-for-leak-kinds=none --fullpath-after='
381-
f' {python} -m pytest {pytest_options} {pytest_arg}'
387+
f' {python} -m pytest {pytest_options}{pytest_arg}'
382388
)
383389
env_extra=dict(
384390
PYTHONMALLOC='malloc',

0 commit comments

Comments
 (0)