File: test_url_images.py

package info (click to toggle)
fpdf2 2.8.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 114,352 kB
  • sloc: python: 50,410; sh: 133; makefile: 12
file content (24 lines) | stat: -rw-r--r-- 589 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import socket
import pytest

from pathlib import Path
from urllib.error import HTTPError

import pytest

import fpdf
from test.conftest import assert_pdf_equal

HERE = Path(__file__).resolve().parent
PNG_IMG_URL = "https://placehold.co/300x200.png"


@pytest.mark.skip(reason="requires internet access")
def test_png_url(tmp_path):
    pdf = fpdf.FPDF()
    pdf.add_page()
    try:
        pdf.image(PNG_IMG_URL, x=15, y=15, w=30, h=25)
    except (HTTPError, socket.timeout) as e:
        pytest.skip(f"Network error: {e}")
    assert_pdf_equal(pdf, HERE / "image_png_url.pdf", tmp_path)