Skip to content

Commit ec43e60

Browse files
scripts/test.py: added --pytest-prefix arg.
1 parent 9699a13 commit ec43e60

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scripts/test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
Whether to rebuild mupdf when we build PyMuPDF. Default is 1.
9595
--gdb 0|1
9696
Run tests under gdb. Requires user interaction.
97+
--pytest-prefix <command>
98+
Use specified prefix when running pytest. E.g. `gdb --args`.
9799
--pybind 0|1
98100
Experimental, for investigating
99101
https://github.com/pymupdf/PyMuPDF/issues/3869. Runs run basic code
@@ -185,6 +187,7 @@ def main(argv):
185187
implementations = 'r'
186188
test_names = list()
187189
venv = 2
190+
pytest_prefix = None
188191
pybind = False
189192
pytest_options = None
190193
timeout = None
@@ -236,6 +239,8 @@ def main(argv):
236239
value = next(args)
237240
assert value in ('0', '1'), f'`-s` must be followed by `0` or `1`, not {value=}.'
238241
os.environ['PYMUPDF_SETUP_PY_LIMITED_API'] = value
242+
elif arg == '--pytest-prefix':
243+
pytest_prefix = next(args)
239244
elif arg == '--pybind':
240245
pybind = int(next(args))
241246
elif arg == '--system-site-packages':
@@ -312,6 +317,7 @@ def do_test():
312317
pytest_options=pytest_options,
313318
timeout=timeout,
314319
gdb=gdb,
320+
pytest_prefix=pytest_prefix,
315321
test_fitz=test_fitz,
316322
pytest_k=pytest_k,
317323
pybind=pybind,
@@ -603,6 +609,7 @@ def test(
603609
pytest_options=None,
604610
timeout=None,
605611
gdb=False,
612+
pytest_prefix=None,
606613
test_fitz=True,
607614
pytest_k=None,
608615
pybind=False,
@@ -624,6 +631,8 @@ def test(
624631
See top-level option `-p`.
625632
gdb:
626633
See top-level option `--gdb`.
634+
pytest_prefix:
635+
See top-level option `--pytest-prefix`.
627636
test_fitz:
628637
See top-level option `-f`.
629638
'''
@@ -732,6 +741,8 @@ def getmtime(path):
732741
)
733742
elif gdb:
734743
command = f'{python} {pymupdf_dir_rel}/tests/run_compound.py{run_compound_args} gdb --args {python} -m pytest {pytest_options} {pytest_arg}'
744+
elif pytest_prefix:
745+
command = f'{python} {pymupdf_dir_rel}/tests/run_compound.py{run_compound_args} {pytest_prefix} {python} -m pytest {pytest_options} {pytest_arg}'
735746
elif platform.system() == 'Windows':
736747
# `python -m pytest` doesn't seem to work.
737748
command = f'{python} {pymupdf_dir_rel}/tests/run_compound.py{run_compound_args} pytest {pytest_options} {pytest_arg}'

0 commit comments

Comments
 (0)