qurator-spk / dinglehopper

An OCR evaluation tool
Apache License 2.0
58 stars 12 forks source link

Tests on 3.12 broken #117

Closed mikegerber closed 1 month ago

mikegerber commented 1 month ago

From GitHub Actions log:

ImportError while importing test module '/home/runner/work/dinglehopper/dinglehopper/src/dinglehopper/tests/test_integ_ocrd_cli.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
dinglehopper/tests/test_integ_ocrd_cli.py:10: in <module>
    from ..ocrd_cli import ocrd_dinglehopper
dinglehopper/ocrd_cli.py:8: in <module>
    from pkg_resources import resource_string
E   ModuleNotFoundError: No module named 'pkg_resources'
mikegerber commented 1 month ago

I can reproduce locally (clean 3.12 pyenv virtualenv, with requirements*.txt installed):

❯ pytest
======================================== test session starts =========================================
platform linux -- Python 3.12.3, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/b-mg106/devel/dinglehopper
configfile: pyproject.toml
plugins: anyio-4.4.0, cov-5.0.0, mypy-0.10.3, ruff-0.3.2
collected 76 items / 1 error

=============================================== ERRORS ===============================================
___________________ ERROR collecting src/dinglehopper/tests/test_integ_ocrd_cli.py ___________________
ImportError while importing test module '/home/b-mg106/devel/dinglehopper/src/dinglehopper/tests/test_integ_ocrd_cli.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../.pyenv/versions/3.12.3/lib/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
src/dinglehopper/tests/test_integ_ocrd_cli.py:10: in <module>
    from ..ocrd_cli import ocrd_dinglehopper
src/dinglehopper/ocrd_cli.py:8: in <module>
    from pkg_resources import resource_string
E   ModuleNotFoundError: No module named 'pkg_resources'
====================================== short test summary info =======================================
ERROR src/dinglehopper/tests/test_integ_ocrd_cli.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================== 1 error in 9.87s ==========================================
mikegerber commented 1 month ago

This is fun:

💩

mikegerber commented 1 month ago

4047f8b fixes this by using the backports in PyPI's importlib_resources + the recommended files().joinpath().read_text() method.

👀 @kba @bertsky This might come up elsewhere when on Python 3.12

mikegerber commented 1 month ago

Reopening: needs new release.

(Not sure why this didn't come up with my earlier tests on Python 3.12 - might be a setuptools update that caused this.)

mikegerber commented 1 month ago

Reopening: needs new release.

https://github.com/qurator-spk/dinglehopper/releases/tag/v0.9.7