adamchainz / time-machine

Travel through time in your tests.
MIT License
710 stars 34 forks source link

Timezone related tests fails on OpenIndiana #386

Closed mtelka closed 2 months ago

mtelka commented 1 year ago

Python Version

3.9.16

pytest Version

7.4.2

Package Version

HEAD from git

Description

I'm trying to run tests on OpenIndiana and four of them fails:

$ git clone https://github.com/adamchainz/time-machine.git
...
$ cd time-machine/
$ PATH=/usr/gcc/10/bin/:$PATH tox -e py39
py39: install_deps> python -I -m pip install -r requirements/py39.txt
.pkg: install_requires> python -I -m pip install setuptools
.pkg: _optional_hooks> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: get_requires_for_build_wheel> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True setuptools.build_meta
.pkg: install_requires_for_build_wheel> python -I -m pip install wheel
.pkg: build_wheel> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True setuptools.build_meta
py39: install_package_deps> python -I -m pip install python-dateutil
py39: install_package> python -I -m pip install --force-reinstall --no-deps /data/builds/time-machine/.tox/.tmp/package/1/time_machine-2.13.0-cp39-cp39-solaris_2_11_i86pc_64bit.whl
py39: commands[0]> python -W error::ResourceWarning -W error::DeprecationWarning -W error::PendingDeprecationWarning -W ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning -W ignore:datetime.datetime.utcnow:DeprecationWarning -m coverage run -m pytest tests
=================================================================================================================== test session starts ====================================================================================================================
platform sunos5 -- Python 3.9.16, pytest-7.4.2, pluggy-1.3.0
cachedir: .tox/py39/.pytest_cache
Using --randomly-seed=3836100381
rootdir: /data/builds/time-machine
configfile: pyproject.toml
plugins: time-machine-2.13.0, randomly-3.15.0
collected 96 items                                                                                                                                                                                                                                         

tests/test_time_machine.py .s...F..........F.........................F....................F................................                                                                                                                          [100%]

========================================================================================================================= FAILURES =========================================================================================================================
_____________________________________________________________________________________________________ test_destination_datetime_tzinfo_zoneinfo_nested _____________________________________________________________________________________________________

    def test_destination_datetime_tzinfo_zoneinfo_nested():
        orig_tzname = time.tzname

        dest = LIBRARY_EPOCH_DATETIME.replace(tzinfo=ZoneInfo("Africa/Addis_Ababa"))
        with time_machine.travel(dest):  
>           assert time.tzname == ("EAT", "EAT")
E           AssertionError: assert ('EAT', '   ') == ('EAT', 'EAT')
E             At index 1 diff: '   ' != 'EAT'
E             Use -v to get more diff

tests/test_time_machine.py:409: AssertionError
________________________________________________________________________________________________________ test_destination_datetime_tzinfo_zoneinfo _________________________________________________________________________________________________________

    def test_destination_datetime_tzinfo_zoneinfo():
        orig_timezone = time.timezone
        orig_altzone = time.altzone
        orig_tzname = time.tzname
        orig_daylight = time.daylight

        dest = LIBRARY_EPOCH_DATETIME.replace(tzinfo=ZoneInfo("Africa/Addis_Ababa"))
        with time_machine.travel(dest):  
            assert time.timezone == -3 * 3600
>           assert time.altzone == -3 * 3600
E           assert 0 == (-3 * 3600)
E            +  where 0 = time.altzone

tests/test_time_machine.py:380: AssertionError
___________________________________________________________________________________________________ test_destination_datetime_tzinfo_zoneinfo_no_orig_tz ___________________________________________________________________________________________________

    def test_destination_datetime_tzinfo_zoneinfo_no_orig_tz():
        with change_local_timezone(None):
            orig_tzname = time.tzname
            dest = LIBRARY_EPOCH_DATETIME.replace(tzinfo=ZoneInfo("Africa/Addis_Ababa"))

            with time_machine.travel(dest):
>               assert time.tzname == ("EAT", "EAT")
E               AssertionError: assert ('EAT', '   ') == ('EAT', 'EAT')
E                 At index 1 diff: '   ' != 'EAT'
E                 Use -v to get more diff

tests/test_time_machine.py:426: AssertionError
________________________________________________________________________________________________________ test_move_to_datetime_with_tzinfo_zoneinfo ________________________________________________________________________________________________________

    def test_move_to_datetime_with_tzinfo_zoneinfo():
        orig_timezone = time.timezone
        orig_altzone = time.altzone
        orig_tzname = time.tzname
        orig_daylight = time.daylight

        with time_machine.travel(EPOCH) as traveller:
            assert time.time() == EPOCH  
            assert time.timezone == orig_timezone
            assert time.altzone == orig_altzone
            assert time.tzname == orig_tzname
            assert time.daylight == orig_daylight

            dest = EPOCH_PLUS_ONE_YEAR_DATETIME.replace(
                tzinfo=ZoneInfo("Africa/Addis_Ababa")
            )
            traveller.move_to(dest)

            assert time.timezone == -3 * 3600
>           assert time.altzone == -3 * 3600
E           assert 0 == (-3 * 3600)
E            +  where 0 = time.altzone

tests/test_time_machine.py:681: AssertionError
================================================================================================================= short test summary info ==================================================================================================================
FAILED tests/test_time_machine.py::test_destination_datetime_tzinfo_zoneinfo_nested - AssertionError: assert ('EAT', '   ') == ('EAT', 'EAT')
FAILED tests/test_time_machine.py::test_destination_datetime_tzinfo_zoneinfo - assert 0 == (-3 * 3600)
FAILED tests/test_time_machine.py::test_destination_datetime_tzinfo_zoneinfo_no_orig_tz - AssertionError: assert ('EAT', '   ') == ('EAT', 'EAT')
FAILED tests/test_time_machine.py::test_move_to_datetime_with_tzinfo_zoneinfo - assert 0 == (-3 * 3600)
========================================================================================================= 4 failed, 91 passed, 1 skipped in 4.37s ==========================================================================================================
py39: exit 1 (7.05 seconds) /data/builds/time-machine> python -W error::ResourceWarning -W error::DeprecationWarning -W error::PendingDeprecationWarning -W ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning -W ignore:datetime.datetime.utcnow:DeprecationWarning -m coverage run -m pytest tests pid=18858
.pkg: _exit> python /usr/lib/python3.9/vendor-packages/pyproject_api/_backend.py True setuptools.build_meta
  py39: FAIL code 1 (51.61=setup[44.56]+cmd[7.05] seconds)
  evaluation failed :( (53.55 seconds)
$

This is followup after #361.

adamchainz commented 2 months ago

Sorry, I don't have time to support running the tests outside of the exact tox-based setup in this repo.