Skip to content

Commit

Permalink
BUG: test_image_without_pillow cannot find pypdf (#2850)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kaos-ocs authored Sep 15, 2024
1 parent 8ebd311 commit 8eefba8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def test_issue_399():

@pytest.mark.enable_socket()
def test_image_without_pillow(tmp_path):
import os
name = "tika-914102.pdf"
pdf_path = Path(__file__).parent / "pdf_cache" / name
pdf_path_str = str(pdf_path.resolve()).replace("\\", "/")
Expand All @@ -273,9 +274,15 @@ def test_image_without_pillow(tmp_path):
), exc.value.args[0]
"""
)
env = os.environ.copy()
try:
env["PYTHONPATH"] = "." + os.pathsep + env["PYTHONPATH"]
except KeyError:
env["PYTHONPATH"] = "."
result = subprocess.run(
[shutil.which("python"), source_file], # noqa: S603
capture_output=True,
env=env,
)
assert result.returncode == 0
assert result.stdout == b""
Expand Down

0 comments on commit 8eefba8

Please sign in to comment.