jaraco / tempora

MIT License
20 stars 5 forks source link

5.6.0: pytest fails with python 3.10 on tests/compat/py38.py #32

Open kloczek opened 2 weeks ago

kloczek commented 2 weeks ago

Looks like on higher versions tests/compat/py38.py should be skipped

==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/tempora-5.6.0
configfile: pytest.ini
collected 23 items / 1 error

========================================================================================== ERRORS ===========================================================================================
__________________________________________________________________________ ERROR collecting tests/test_schedule.py __________________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/tempora-5.6.0/tests/test_schedule.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_schedule.py:11: in <module>
    from .compat.py38 import zoneinfo
E   ImportError: cannot import name 'zoneinfo' from 'tests.compat.py38' (/home/tkloczko/rpmbuild/BUILD/tempora-5.6.0/tests/compat/py38.py)
================================================================================== short test summary info ==================================================================================
ERROR tests/test_schedule.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 1 error in 0.19s ======================================================================================
kloczek commented 2 weeks ago

Also ..

[tkloczko@pers-jacek tempora-5.6.0]$ grep -r compat.py38
tempora/schedule.py:>>> from tests.compat.py38 import zoneinfo
tests/test_schedule.py:from .compat.py38 import zoneinfo

Looks like in those places could be used something like

if sys.version_info >= (3, 9):
    import zoneinfo
else:
    from .compat.py38 import zoneinfo