GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — rhwp-python/tests/test_pdf_rendering.py at main · DanMeon/rhwp-python

Expand file tree

/

test_pdf_rendering.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
42 lines (32 loc) · 1.5 KB
/

test_pdf_rendering.py

Copy path

File metadata and controls

42 lines (32 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""PDF 렌더링 API 검증 — @slow (usvg + pdf-writer 병목)."""
from pathlib import Path
import pytest
import rhwp
pytestmark = [pytest.mark.slow, pytest.mark.spec("v0.1.0/rhwp-python")]
# ^ soft retrofit — file-level spec mapping; v0.4.0+ specs add #AC-N to specific tests
class TestRenderPdf:
def test_returns_bytes(self, parsed_hwpx: rhwp.Document) -> None:
# ^ 가이드 §12.4: Bound<'py, PyBytes> 바인딩으로 Python bytes 직접 반환
# (list[int] 노출 금지)
pdf = parsed_hwpx.render_pdf()
assert isinstance(pdf, bytes)
def test_pdf_signature(self, parsed_hwpx: rhwp.Document) -> None:
pdf = parsed_hwpx.render_pdf()
assert pdf.startswith(b"%PDF-")
assert len(pdf) > 1000
class TestExportPdf:
def test_writes_file(self, parsed_hwpx: rhwp.Document, tmp_path: Path) -> None:
output = tmp_path / "out.pdf"
size = parsed_hwpx.export_pdf(str(output))
assert output.exists()
assert output.stat().st_size == size
def test_pdf_signature_in_file(self, parsed_hwpx: rhwp.Document, tmp_path: Path) -> None:
output = tmp_path / "sig.pdf"
parsed_hwpx.export_pdf(str(output))
with open(output, "rb") as f:
assert f.read(5) == b"%PDF-"
def test_returns_size_as_int(self, parsed_hwpx: rhwp.Document, tmp_path: Path) -> None:
output = tmp_path / "size.pdf"
size = parsed_hwpx.export_pdf(str(output))
assert isinstance(size, int)
assert size > 0
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.