Skip to content

Commit 883b891

Browse files
tests/test_pixmap.py: test_3493(): work around unexpected exception on Github.
1 parent da2bfe6 commit 883b891

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/test_pixmap.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def test_3493():
284284
in_path = f'{root}/tests/resources/test_3493.epub'
285285

286286
def run(command, check=1, stdout=None):
287-
print(f'Running: {command}')
287+
print(f'Running with {check=}: {command}')
288288
return subprocess.run(command, shell=1, check=check, stdout=stdout, text=1)
289289

290290
def run_code(code, code_path, *, check=True, venv=None, venv_args='', pythonpath=None, stdout=None):
@@ -293,7 +293,14 @@ def run_code(code, code_path, *, check=True, venv=None, venv_args='', pythonpath
293293
f.write(code)
294294
prefix = f'PYTHONPATH={pythonpath} ' if pythonpath else ''
295295
if venv:
296-
run(f'{sys.executable} -m venv {venv_args} {venv}')
296+
# Have seen this fail on Github in a curious way:
297+
#
298+
# Running: /tmp/tmp.fBeKNLJQKk/venv/bin/python -m venv --system-site-packages /project/tests/resources/test_3493_venv
299+
# Error: [Errno 2] No such file or directory: '/project/tests/resources/test_3493_venv/bin/python'
300+
#
301+
r = run(f'{sys.executable} -m venv {venv_args} {venv}', check=check)
302+
if r.returncode:
303+
return r
297304
r = run(f'. {venv}/bin/activate && {prefix}python {code_path}', check=check, stdout=stdout)
298305
else:
299306
r = run(f'{prefix}{sys.executable} {code_path}', check=check, stdout=stdout)

0 commit comments

Comments
 (0)