"""Erzeugt die QA-Fixtures 01–14 (synthetisch, DRM-frei) unter .qa/generated-fixtures/.""" from __future__ import annotations import sys import zipfile from pathlib import Path ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, str(ROOT / "tests")) from conftest import PNG, SVG, Book, Doc, build_epub # noqa: E402 OUT = ROOT / ".qa" / "generated-fixtures" M = 'xmlns="http://www.w3.org/1998/Math/MathML"' def rewrite(path: Path, changes: dict[str, bytes | None], extra: dict[str, bytes] | None = None) -> None: """Replace/delete entries of an existing ZIP and add raw entries (names unchanged, even unsafe ones).""" with zipfile.ZipFile(path) as z: entries = [(i, z.read(i)) for i in z.infolist()] with zipfile.ZipFile(path, "w") as z: for info, data in entries: if info.filename in changes: if changes[info.filename] is None: continue data = changes[info.filename] z.writestr(info, data) for name, data in (extra or {}).items(): z.writestr(zipfile.ZipInfo(name), data) def f01() -> Book: return Book(version="2.0", ncx=True, title="Minimal EPUB 2", authors=["Ada Lovelace"], language="en", identifier="urn:uuid:11111111-2222-3333-4444-555555555555", docs=[Doc("chapter1.xhtml", "
Hello EPUB 2 world.
", "Chapter One")]) def f02() -> Book: return Book(title="Minimal EPUB 3", authors=["Grace Hopper"], docs=[Doc("c1.xhtml", "Eins.
", "Erstes Kapitel"), Doc("c2.xhtml", "Zwei.
", "Zweites Kapitel")]) def f03() -> Book: a = ('Zu Kapitel B, zum Anker unten, ' 'zum Ziel in B und ins Nichts, ' 'sowie fehlender Anker.
' 'Text A.1
' 'Unten in A2.
' 'Mehr.
') b = ('B-Text.
Ziel in B.
' '') c = 'Ende mit Link auf A.
' return Book(title="Kapitel und Links", docs=[Doc("a.xhtml", a, "A"), Doc("b.xhtml", b, "B"), Doc("c.xhtml", c, "C")]) PY = """class Stack: def __init__(self): self.items = [] def push(self, x): \tself.items.append(x) # Tab-Einrückung if len(self.items) > 10 and x < 0: raise ValueError("& zu voll") """ def f04() -> Book: body = ( "Inline: len(x) < 3 && y, mit Backtick a`b und *nicht kursiv*.
{PY}'
"$ find . -name '*.py' | xargs grep -n \"TODO\" \\\n | sort -u > todo.txt\n$ echo $HOME" "
Markdown mit ```fences``` und `ticks`\n eingerückt"
'{\n "a": [1, 2],\n "b": "<tag>"\n}'
"#include <stdio.h>\nint main(void) { return 0; }"
"Unbekanntes Element:
| Befehl | Bedeutung |
|---|---|
ls | wc -l | Dateien zählen |
a && b | und |
'
"Nochmals dasselbe Foto: 
Inline-SVG:
' 'Siehe Abbildung 1.1 und SVG direkt.
' 'Fehlendes Bild: 
Bruch inline: .
" f"Potenz: , Index: , " f"beides: .
" f'Nach Gleichung (2.1) folgt …
' f'Nicht unterstützt: .
' f'Mit TeX-Annotation: .
" f'alttext: .
' 'SVG-Formel:
Bildformel: 
(2.2)Aussage A1 und B' '2, nochmal A1.
' '' '' f'" ) notes = ( 'Der Begriff API und ' 'Rekursion nach Knuth [Knu97].
') glossary = ('Selbstaufruf einer Funktion.
Siehe auch Iteration.
API Glossar
Knuth, Donald E. 17
| Probe | Messung | |
|---|---|---|
| vorher | nachher | |
| A | 1,5 korrigiert | 2,0 |
| B | ausgefallen siehe Text | |
'
'escape 