From 523afa840a84bababa3d7708bd9a4030cec0b025 Mon Sep 17 00:00:00 2001 From: matsidzi <60542384+matsidzi@users.noreply.github.com> Date: Thu, 15 Aug 2024 23:17:16 +0300 Subject: [PATCH] TST: Added test for date_range for bug GH#57456 (#59519) TST: Added test for date_range for bug #57456 Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- .../tests/indexes/datetimes/test_date_range.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pandas/tests/indexes/datetimes/test_date_range.py b/pandas/tests/indexes/datetimes/test_date_range.py index 9eb5856c49db8..e09883e95ecec 100644 --- a/pandas/tests/indexes/datetimes/test_date_range.py +++ b/pandas/tests/indexes/datetimes/test_date_range.py @@ -1258,6 +1258,24 @@ def test_range_with_timezone_and_custombusinessday(self, start, period, expected expected = DatetimeIndex(expected).as_unit("ns") tm.assert_index_equal(result, expected) + def test_data_range_custombusinessday_partial_time(self, unit): + # GH#57456 + offset = offsets.CustomBusinessDay(weekmask="Sun Mon Tue") + start = datetime(2024, 2, 6, 23) + # end datetime is partial and not in the offset + end = datetime(2024, 2, 14, 14) + result = date_range(start, end, freq=offset, unit=unit) + expected = DatetimeIndex( + [ + "2024-02-06 23:00:00", + "2024-02-11 23:00:00", + "2024-02-12 23:00:00", + "2024-02-13 23:00:00", + ], + dtype=f"M8[{unit}]", + ) + tm.assert_index_equal(result, expected) + class TestDateRangeNonNano: def test_date_range_reso_validation(self):