Skip to content

Commit 6ca763f

Browse files
scripts/ tests/: avoid spurious test failure with sysinstall.
scripts/sysinstall.py: Set PYMUPDF_SYSINSTALL_TEST=1 when running tests. tests/test_pixmap.py:test_3854(): Accept non-zero rms if PYMUPDF_SYSINSTALL_TEST is 1. tests/test_pylint.py: Allow `if 0 and ...`:
1 parent 2a306b1 commit 6ca763f

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

scripts/sysinstall.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ def main():
190190
sudo = ''
191191
if root == '/':
192192
sudo = f'sudo PATH={os.environ["PATH"]} '
193-
def run(command):
194-
return run_command(command, doit=mupdf_do)
193+
def run(command, env_extra=None):
194+
return run_command(command, doit=mupdf_do, env_extra=env_extra)
195195
# Get MuPDF from git if specified.
196196
#
197197
if mupdf_git:
@@ -334,8 +334,8 @@ def run(command):
334334
# Run pytest tests.
335335
#
336336
log('## Run PyMuPDF pytest tests.')
337-
def run(command):
338-
return run_command(command, doit=pytest_do)
337+
def run(command, env_extra=None):
338+
return run_command(command, doit=pytest_do, env_extra=env_extra)
339339
import gh_release
340340
if pip == 'venv':
341341
# Create venv.
@@ -387,12 +387,12 @@ def run(command):
387387
command += f' -p {shlex.quote(pytest_args)}'
388388
if pytest_do:
389389
command += ' test'
390-
run(command)
390+
run(command, env_extra=dict(PYMUPDF_SYSINSTALL_TEST='1'))
391391

392392

393-
def run_command(command, capture=False, check=True, doit=True):
393+
def run_command(command, capture=False, check=True, doit=True, env_extra=None):
394394
if doit:
395-
return pipcl.run(command, capture=capture, check=check, caller=2)
395+
return pipcl.run(command, capture=capture, check=check, caller=2, env_extra=env_extra)
396396
else:
397397
log(f'## Would have run: {command}', caller=2)
398398

tests/test_pixmap.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,4 +426,9 @@ def test_3854():
426426

427427
rms = gentle_compare.pixmaps_rms(pixmap, pixmap_expected)
428428
print(f'{rms=}.')
429-
assert rms == 0
429+
if os.environ.get('PYMUPDF_SYSINSTALL_TEST') == '1':
430+
# MuPDF using external third-party libs gives slightly different
431+
# behaviour.
432+
assert rms < 1
433+
else:
434+
assert rms == 0

tests/test_pylint.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_pylint():
3636
W0622: Redefining built-in 'open' (redefined-builtin)
3737
W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
3838
R1734: Consider using [] instead of list() (use-list-literal)
39+
R1727: Boolean condition '0 and g_exceptions_verbose' will always evaluate to '0' (condition-evals-to-constant)
3940
'''
4041
)
4142

0 commit comments

Comments
 (0)