From: Radek Czajka Date: Mon, 28 Apr 2025 12:04:42 +0000 (+0200) Subject: fix tests X-Git-Tag: 24.5.9~1 X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/923ab131bfa43b0ceb8010669133c09e963b8563 fix tests --- diff --git a/setup.py b/setup.py index df8212c..41fa6a4 100755 --- a/setup.py +++ b/setup.py @@ -40,11 +40,11 @@ setup( 'Pillow>=9.1.0', 'texml', 'ebooklib', - 'aeneas', 'mutagen', 'qrcode', 'requests', 'fonttools', + 'python-bidi', ], entry_points = { "console_scripts": [ diff --git a/src/librarian/builders/daisy.py b/src/librarian/builders/daisy.py index c706cbd..bdfc306 100644 --- a/src/librarian/builders/daisy.py +++ b/src/librarian/builders/daisy.py @@ -5,8 +5,6 @@ from copy import deepcopy import subprocess import tempfile import zipfile -from aeneas.executetask import ExecuteTask -from aeneas.task import Task from lxml import etree import mutagen from librarian import OutputFile, get_resource @@ -117,7 +115,7 @@ class DaisyBuilder: directory + "book%d.mp3" % i, ) - config_string = "task_language=pol|is_text_type=unparsed|is_text_unparsed_id_regex=sec\d+$|is_text_unparsed_id_sort=numeric|os_task_file_format=tab" + config_string = "task_language=pol|is_text_type=unparsed|is_text_unparsed_id_regex=sec\\d+$|is_text_unparsed_id_sort=numeric|os_task_file_format=tab" task = Task(config_string=config_string) with tempfile.TemporaryDirectory() as temp: diff --git a/src/librarian/elements/base.py b/src/librarian/elements/base.py index b0d16ed..f430c23 100644 --- a/src/librarian/elements/base.py +++ b/src/librarian/elements/base.py @@ -136,7 +136,7 @@ class WLElement(etree.ElementBase): for i, child in enumerate(self): if isinstance(child, WLElement): getattr(child, build_method)(builder) - elif getattr(builder, 'debug') and child.tag is etree.Comment: + elif getattr(builder, 'debug', False) and child.tag is etree.Comment: builder.process_comment(child) if self.CAN_HAVE_TEXT and child.tail: text = self.normalize_text(child.tail, builder) diff --git a/src/librarian/html.py b/src/librarian/html.py index d6482dc..73ea15d 100644 --- a/src/librarian/html.py +++ b/src/librarian/html.py @@ -113,7 +113,10 @@ def transform(wldoc, stylesheet='legacy', options=None, flags=None, css=None, ga document.edoc.getroot().set(flag, 'yes') ltag = document.edoc.find('//' + DCNS('language')) - lang = functions.lang_code_3to2(ltag.text) or 'pl' + if ltag is not None: + lang = functions.lang_code_3to2(ltag.text) + else: + lang = 'pl' document.edoc.getroot().set('lang', lang) document.clean_ed_note() diff --git a/tests/files/text/asnyk_miedzy_nami_expected.legacy.html b/tests/files/text/asnyk_miedzy_nami_expected.legacy.html index 7004f5a..64fea81 100644 --- a/tests/files/text/asnyk_miedzy_nami_expected.legacy.html +++ b/tests/files/text/asnyk_miedzy_nami_expected.legacy.html @@ -1,4 +1,4 @@ -
+

Spis treści

    @@ -34,14 +34,14 @@
    Prócz tych wspólnych, jasnych zdrojów,
    Z których serce zachwyt piło;
    - 15
    Prócz pierwiosnków[1] i powojów,—
    + 15
    Prócz pierwiosnków[1] i powojów,—
    Między nami nic nie było!

    Przypisy

    -[1]

    pierwiosnek — taki kwiatek [przypis edytorski]

    +[1]

    pierwiosnek — taki kwiatek [przypis edytorski]

    diff --git a/tox.ini b/tox.ini index ecf3ecc..489be44 100644 --- a/tox.ini +++ b/tox.ini @@ -1,26 +1,27 @@ [tox] envlist = clean, - py{37,38,39,310,311}, + py{38,39,310,311,312}, stats [testenv] deps = coverage -passenv = HOME ; Needed to find locally installed fonts when testing PDF production. +; Needed to find locally installed fonts when testing PDF production. +passenv = HOME download = true commands = coverage run -install_command = pip install numpy; pip install --extra-index-url https://py.mdrn.pl/simple {packages} +install_command = pip install --extra-index-url https://py.mdrn.pl/simple {packages} [testenv:clean] -basepython = python3 +basepython = python312 commands = coverage erase deps = coverage [testenv:stats] -basepython = python3 +basepython = python312 commands = coverage combine coverage report