Skip to content

Commit 8eefba8

Browse files
authored
BUG: test_image_without_pillow cannot find pypdf (#2850)
test_image_without_pillow runs a generated script which causes the Python path to exclude the current directory. The generated script tries to import pypdf and either cannot find it or it finds the version in pyenv instead of the version being tested. Add "." to PYTHONPATH so the correct version of pypdf is used. Closes #2849
1 parent 8ebd311 commit 8eefba8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/test_filters.py

+7
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def test_issue_399():
248248

249249
@pytest.mark.enable_socket()
250250
def test_image_without_pillow(tmp_path):
251+
import os
251252
name = "tika-914102.pdf"
252253
pdf_path = Path(__file__).parent / "pdf_cache" / name
253254
pdf_path_str = str(pdf_path.resolve()).replace("\\", "/")
@@ -273,9 +274,15 @@ def test_image_without_pillow(tmp_path):
273274
), exc.value.args[0]
274275
"""
275276
)
277+
env = os.environ.copy()
278+
try:
279+
env["PYTHONPATH"] = "." + os.pathsep + env["PYTHONPATH"]
280+
except KeyError:
281+
env["PYTHONPATH"] = "."
276282
result = subprocess.run(
277283
[shutil.which("python"), source_file], # noqa: S603
278284
capture_output=True,
285+
env=env,
279286
)
280287
assert result.returncode == 0
281288
assert result.stdout == b""

0 commit comments

Comments
 (0)