HTML-Kommentare zählten als Text (1435 Blöcke in einem Testbuch), Leerraum wurde mit Pythons statt JavaScripts \s zusammengezogen, Fußnotenmarker bekamen Leerzeichen. Neu: tests/ (Blockliste, Anker, App-Start mit Textual-Pilot) und tools/parity/ – vergleicht Anzahl und Tags der Blöcke mit parseEpub aus dem Web-Reader in headless Chromium (6 Bücher, bis 25.798 Blöcke: gleich). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
30 lines
1 KiB
Python
30 lines
1 KiB
Python
"""The Textual app starts, lists a library, opens a book and leaves it again."""
|
|
import asyncio
|
|
|
|
from diora_tui.app import DioraTuiApp
|
|
from diora_tui.reader_screen import ReaderScreen
|
|
|
|
|
|
def test_open_read_and_leave(epub, tmp_path):
|
|
lib = tmp_path / "lib"
|
|
lib.mkdir()
|
|
path = epub(["<h1>Anfang</h1>" + "".join(f"<p>Absatz {i} " + "wort " * 40 + "</p>" for i in range(60))])
|
|
path.rename(lib / path.name)
|
|
|
|
async def run():
|
|
app = DioraTuiApp(lib)
|
|
async with app.run_test(size=(100, 30)) as pilot:
|
|
await pilot.pause()
|
|
await pilot.press("enter")
|
|
for _ in range(50):
|
|
await pilot.pause(0.1)
|
|
if isinstance(app.screen, ReaderScreen):
|
|
break
|
|
assert isinstance(app.screen, ReaderScreen)
|
|
await pilot.pause(0.5)
|
|
await pilot.press("j", "j", "j", "n")
|
|
await pilot.press("escape")
|
|
await pilot.pause()
|
|
assert not isinstance(app.screen, ReaderScreen)
|
|
|
|
asyncio.run(run())
|