Skip to content

Commit

Permalink
TST: Fix test_image_without_pillow in windows environment (#2257)
Browse files Browse the repository at this point in the history
  • Loading branch information
pubpub-zz committed Oct 18, 2023
1 parent 2a3c1fb commit f27b72d
Showing 1 changed file with 7 additions and 6 deletions.
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

0 comments on commit f27b72d

Please sign in to comment.