Skip to content

Commit

Permalink
scripts/ tests/: avoid spurious test failure with sysinstall.
Browse files Browse the repository at this point in the history
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 ...`:
  • Loading branch information
julian-smith-artifex-com committed Dec 3, 2024
1 parent 2a306b1 commit 6ca763f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 7 additions & 7 deletions scripts/sysinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ def main():
sudo = ''
if root == '/':
sudo = f'sudo PATH={os.environ["PATH"]} '
def run(command):
return run_command(command, doit=mupdf_do)
def run(command, env_extra=None):
return run_command(command, doit=mupdf_do, env_extra=env_extra)
# Get MuPDF from git if specified.
#
if mupdf_git:
Expand Down Expand Up @@ -334,8 +334,8 @@ def run(command):
# Run pytest tests.
#
log('## Run PyMuPDF pytest tests.')
def run(command):
return run_command(command, doit=pytest_do)
def run(command, env_extra=None):
return run_command(command, doit=pytest_do, env_extra=env_extra)
import gh_release
if pip == 'venv':
# Create venv.
Expand Down Expand Up @@ -387,12 +387,12 @@ def run(command):
command += f' -p {shlex.quote(pytest_args)}'
if pytest_do:
command += ' test'
run(command)
run(command, env_extra=dict(PYMUPDF_SYSINSTALL_TEST='1'))


def run_command(command, capture=False, check=True, doit=True):
def run_command(command, capture=False, check=True, doit=True, env_extra=None):
if doit:
return pipcl.run(command, capture=capture, check=check, caller=2)
return pipcl.run(command, capture=capture, check=check, caller=2, env_extra=env_extra)
else:
log(f'## Would have run: {command}', caller=2)

Expand Down
7 changes: 6 additions & 1 deletion tests/test_pixmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,9 @@ def test_3854():

rms = gentle_compare.pixmaps_rms(pixmap, pixmap_expected)
print(f'{rms=}.')
assert rms == 0
if os.environ.get('PYMUPDF_SYSINSTALL_TEST') == '1':
# MuPDF using external third-party libs gives slightly different
# behaviour.
assert rms < 1
else:
assert rms == 0
1 change: 1 addition & 0 deletions tests/test_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def test_pylint():
W0622: Redefining built-in 'open' (redefined-builtin)
W1309: Using an f-string that does not have any interpolated variables (f-string-without-interpolation)
R1734: Consider using [] instead of list() (use-list-literal)
R1727: Boolean condition '0 and g_exceptions_verbose' will always evaluate to '0' (condition-evals-to-constant)
'''
)

Expand Down

0 comments on commit 6ca763f

Please sign in to comment.