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

DEV: Download PDFs before executing the tests to not run into timeouts #2143

Merged
merged 2 commits into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .github/workflows/github-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ jobs:
- name: Install pypdf
run: |
pip install .
- name: Prepare
run: |
python -c "from tests import download_test_pdfs; download_test_pdfs()"
- name: Test with pytest
run: |
python -m coverage run --parallel-mode -m pytest tests -vv
Expand Down
11 changes: 11 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,14 @@ def is_sublist(child_list, parent_list):
if parent_list[0] == child_list[0]:
return is_sublist(child_list[1:], parent_list[1:])
return is_sublist(child_list, parent_list[1:])


def download_test_pdfs():
"""
Run this before the tests are executed to ensure you have everything locally.

This is especially important to avoid pytest timeouts.
"""
pdfs = [("https://arxiv.org/pdf/2201.00214.pdf", "2201.00214.pdf")]
for url, name in pdfs:
get_data_from_url(url, name=name)
2 changes: 1 addition & 1 deletion tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ def test_watermarking_speed():
name = "bgwatermark.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
url = "https://arxiv.org/pdf/2201.00214.pdf"
name = "src_doc.pdf"
name = "2201.00214.pdf"
writer = PdfWriter(clone_from=BytesIO(get_data_from_url(url, name=name)))
for p in writer.pages:
p.merge_page(reader.pages[0], over=False)
Expand Down