2 tests fail: AssertionError: assert <DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD> == zoneinfo.ZoneInfo(key='America/New_York')
yurivict opened this issue · 10 comments
========================================================================================= FAILURES ==========================================================================================
__________________________________________________________________________________ test_basic_information ___________________________________________________________________________________
def test_basic_information():
assert mcal_iepa._EC_NOT_INITIALIZED
> assert mcal_iepa.tz == ZoneInfo("America/New_York") == ecal_iepa.tz
E AssertionError: assert <DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD> == zoneinfo.ZoneInfo(key='America/New_York')
E + where <DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD> = <pandas_market_calendars.class_registry.IEPA object at 0x2cd91801de20>.tz
E + and zoneinfo.ZoneInfo(key='America/New_York') = ZoneInfo('America/New_York')
tests/test_market_calendar.py:1590: AssertionError
______________________________________________________________________________________ test_time_zone _______________________________________________________________________________________
def test_time_zone():
> assert xnys_cal.tz == ZoneInfo("America/New_York")
E AssertionError: assert <DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD> == zoneinfo.ZoneInfo(key='America/New_York')
E + where <DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD> = <pandas_market_calendars.class_registry.XNYS object at 0x2cd917d70250>.tz
E + and zoneinfo.ZoneInfo(key='America/New_York') = ZoneInfo('America/New_York')
tests/test_XNYS_calendar.py:19: AssertionError
======================================================================== 2 failed, 1404 passed in 479.86s (0:07:59) =========================================================================
Version: 4.4.0
pandas-2.0.3
python-3.9
FreeBSD 14.0
Can you provide more information, as all tests pass on every configuration I test
Tests are run with this command:
===> py311-pandas-market-calendars-4.4.0_1 depends on file: /usr/local/bin/python3.11 - found
cd /usr/ports/finance/py-pandas-market-calendars/work-py311/pandas_market_calendars-4.4.0 && /usr/bin/env -i HOME=/usr/ports/finance/py-pandas-market-calendars/work-py311 PWD="${PWD}" __MAKE_CONF=/nonexistent OSVERSION=1401500 PATH=/usr/local/libexec/ccache:/usr/ports/finance/py-pandas-market-calendars/work-py311/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin TERM=xterm-256color XDG_DATA_HOME=/usr/ports/finance/py-pandas-market-calendars/work-py311 XDG_CONFIG_HOME=/usr/ports/finance/py-pandas-market-calendars/work-py311 XDG_CACHE_HOME=/usr/ports/finance/py-pandas-market-calendars/work-py311/.cache HOME=/usr/ports/finance/py-pandas-market-calendars/work-py311 PATH=/usr/local/libexec/ccache:/usr/ports/finance/py-pandas-market-calendars/work-py311/.bin:/home/yuri/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin PKG_CONFIG_LIBDIR=/usr/ports/finance/py-pandas-market-calendars/work-py311/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local LOCALBASE=/usr/local CC="cc" CFLAGS="-O2 -pipe -fstack-protector-strong -fno-strict-aliasing " CPP="cpp" CPPFLAGS="" LDFLAGS=" -fstack-protector-strong " LIBS="" CXX="c++" CXXFLAGS="-O2 -pipe -fstack-protector-strong -fno-strict-aliasing " CCACHE_DIR="/tmp/.ccache" BSD_INSTALL_PROGRAM="install -s -m 555" BSD_INSTALL_LIB="install -s -m 0644" BSD_INSTALL_SCRIPT="install -m 555" BSD_INSTALL_DATA="install -m 0644" BSD_INSTALL_MAN="install -m 444" /usr/local/bin/python3.11 -m pytest -k '' -rs -v -o addopts=
==================================================================================== test session starts ====================================================================================
platform freebsd14 -- Python 3.11.9, pytest-8.1.1, pluggy-1.5.0 -- /usr/local/bin/python3.11
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/usr/ports/finance/py-pandas-market-calendars/work-py311/pandas_market_calendars-4.4.0/.hypothesis/examples'))
Using --randomly-seed=1342849725
rootdir: /usr/ports/finance/py-pandas-market-calendars/work-py311/pandas_market_calendars-4.4.0
configfile: pyproject.toml
plugins: xdist-3.5.0, timeout-2.1.0, time-machine-2.11.0, rerunfailures-11.1.2, flaky-3.8.1, cov-4.1.0, hypothesis-6.98.18, mock-3.10.0, randomly-3.12.0, asyncio-0.23.7, env-0.6.2, aspectlib-2.0.0, datadir-1.5.0
asyncio: mode=Mode.STRICT
collected 1406 items
tests/test_cme_bond_calendar.py::test_2020_noon_15_holidays PASSED [ 0%]
tests/test_cme_bond_calendar.py::test_time_zone PASSED [...]
Now they are still failing with Python-3.11
Could you please tell me what other information can I provide?
The failures boil down to this script failing:
$ cat x.py
from pandas_market_calendars import get_calendar, get_calendar_names
import exchange_calendars as ecal
from zoneinfo import ZoneInfo
mcal_iepa = get_calendar("IEPA")
ecal_iepa = ecal.get_calendar("IEPA")
print(f'mcal_iepa.tz={mcal_iepa.tz} ecal_iepa.tz={ecal_iepa.tz}')
assert True
assert mcal_iepa._EC_NOT_INITIALIZED
assert mcal_iepa.tz == ZoneInfo("America/New_York") == ecal_iepa.tz
$ python3.11 x.py
mcal_iepa.tz=America/New_York ecal_iepa.tz=America/New_York
Traceback (most recent call last):
File "/usr/ports/finance/py-pandas-market-calendars/x.py", line 12, in <module>
assert mcal_iepa.tz == ZoneInfo("America/New_York") == ecal_iepa.tz
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
Replacing the last line with the following fixes the failure:
assert str(mcal_iepa.tz) == str(ZoneInfo("America/New_York")) == str(ecal_iepa.tz)
The reason seems to be that it compares different objects all of which are represented with the same string "America/New_York".
That test passes on my local machine and the TOX build here on GitHub. I would suggest trying a new environment with a fresh installation
I have a fresh installation. I installed from the port from scratch.
py311-backports.zoneinfo-0.2.1_1 is used for ZoneInfo.
For whatever reason it returns a different object compared to the one that pandas_market_calendars uses.
That may be your issue. Perhaps the backport ZoneInfo is not identical to the real ZoneInfo
The complete run of the tests on all versions and infrastructure is here:
https://github.com/rsheftel/pandas_market_calendars/actions/runs/9556424978
What is the script that is used to test pandas_market_calendars?
Here is an intro on how to run pytest