-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TST: Improve test coverage by extracting texts (#998)
- Loading branch information
1 parent
034d7a9
commit 6ce36f7
Showing
7 changed files
with
175 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from io import BytesIO | ||
|
||
import pytest | ||
|
||
from PyPDF2 import PdfReader | ||
from PyPDF2.errors import PdfReadWarning | ||
|
||
from . import get_pdf_from_url | ||
|
||
|
||
def test_compute_space_width(): | ||
url = "https://corpora.tika.apache.org/base/docs/govdocs1/923/923406.pdf" | ||
name = "tika-923406.pdf" | ||
|
||
reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name))) | ||
for page in reader.pages: | ||
page.extract_text() | ||
|
||
|
||
def test_parse_to_unicode_process_rg(): | ||
url = "https://corpora.tika.apache.org/base/docs/govdocs1/959/959173.pdf" | ||
name = "tika-959173.pdf" | ||
|
||
reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name))) | ||
for page in reader.pages: | ||
page.extract_text() | ||
|
||
reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name)), strict=True) | ||
for page in reader.pages: | ||
page.extract_text() | ||
|
||
|
||
def test_parse_encoding_advanced_encoding_not_implemented(): | ||
url = "https://corpora.tika.apache.org/base/docs/govdocs1/957/957144.pdf" | ||
name = "tika-957144.pdf" | ||
|
||
reader = PdfReader(BytesIO(get_pdf_from_url(url, name=name))) | ||
with pytest.warns(PdfReadWarning, match="Advanced encoding .* not implemented yet"): | ||
for page in reader.pages: | ||
page.extract_text() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters