From 5b7c41cffc60ebe2d5642c995f6790fe1d53939c Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Tue, 11 Jul 2023 16:50:38 +0200 Subject: [PATCH] test: Adapt the CustomTimeseries test fixture Comparison of tz-naive and tz-aware datetime-like objects has been removed in Pandas 2.0. See: https://github.com/pandas-dev/pandas/pull/49492/ Signed-off-by: Julien Jerphanion --- .../version_store/test_update_with_date_range.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/tests/integration/arcticdb/version_store/test_update_with_date_range.py b/python/tests/integration/arcticdb/version_store/test_update_with_date_range.py index 73e25aaf63..e220fc6177 100644 --- a/python/tests/integration/arcticdb/version_store/test_update_with_date_range.py +++ b/python/tests/integration/arcticdb/version_store/test_update_with_date_range.py @@ -53,7 +53,14 @@ def __init__(self, wrapped: pd.DataFrame, *, with_timezone_attr: bool, timezone_ def __getitem__(self, item): if isinstance(item, slice): - open_ended = slice(item.start + timedelta(microseconds=1), item.stop - timedelta(microseconds=1), item.step) + # Comparing datetimes with timezone to datetimes without timezone has been deprecated in Pandas 1.2.0 + # (see https://github.com/pandas-dev/pandas/pull/36148/) and is not support anymore in Pandas 2.0 + # (see https://github.com/pandas-dev/pandas/pull/49492/). + # We explicitly remove the timezone from the start and stop of the slice to be able to use the + # index of the wrapped DataFrame. + start_wo_tz = item.start.replace(tzinfo=None) + timedelta(microseconds=1) + stop_wo_tz = item.stop.replace(tzinfo=None) - timedelta(microseconds=1) + open_ended = slice(start_wo_tz, stop_wo_tz, item.step) return CustomTimeseries( self.wrapped[open_ended], with_timezone_attr=self.with_timezone_attr,