Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Fix test_image_without_pillow in windows environment #2257

Merged
merged 3 commits into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,13 @@ def test_issue_399():
reader.pages[1].extract_text()


@pytest.mark.skipif(
sys.platform.startswith("win"),
reason="Supbrocess running python seems to linux-specific",
)
@pytest.mark.enable_socket()
def test_image_without_pillow(tmp_path):
url = "https://corpora.tika.apache.org/base/docs/govdocs1/914/914102.pdf"
name = "tika-914102.pdf"
_ = get_data_from_url(url, name=name)
pdf_path = Path(__file__).parent / "pdf_cache" / name
pdf_path_str = str(pdf_path.resolve()).replace("\\", "/")

source_file = tmp_path / "script.py"
source_file.write_text(
Expand All @@ -281,7 +278,7 @@ def test_image_without_pillow(tmp_path):


sys.modules["PIL"] = None
reader = PdfReader("{pdf_path.resolve()}", strict=True)
reader = PdfReader("{pdf_path_str}", strict=True)

for page in reader.pages:
with pytest.raises(ImportError) as exc:
Expand All @@ -299,7 +296,11 @@ def test_image_without_pillow(tmp_path):
)
assert result.returncode == 0
assert result.stdout == b""
assert result.stderr == b"Superfluous whitespace found in object header b'4' b'0'\n"
assert (
result.stderr.replace(b"\r", b"")
== b"Superfluous whitespace found in object header b'4' b'0'\n"
)



@pytest.mark.enable_socket()
Expand Down
Loading