Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added proper result-expected assertion pattern for tests
  • Loading branch information
sharkipelago committed Jun 11, 2025
commit 5cfd5993ffffc91a17a038a3e2fc0427bcfddcc2
64 changes: 61 additions & 3 deletions pandas/tests/tseries/holiday/test_holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,28 @@ def test_holiday_with_exclusion():

original_dates = default_uk_spring_bank_holiday.dates(start, end)
actual_dates = queens_jubilee_uk_spring_bank_holiday.dates(start, end)
print(exclude.isin(original_dates).all())

assert exclude.isin(original_dates).all()
assert ~exclude.isin(actual_dates).all()
assert actual_dates.isin(original_dates).all()

result = queens_jubilee_uk_spring_bank_holiday.dates(start, end)
expected = DatetimeIndex(
[
Timestamp("2020-05-25"),
Timestamp("2021-05-31"),
Timestamp("2023-05-29"),
Timestamp("2024-05-27"),
Timestamp("2025-05-26"),
],
dtype="datetime64[ns]",
)
tm.assert_index_equal(result, expected)


def test_holiday_with_multiple_exclusions():
start = Timestamp("2000-01-01")
end = Timestamp("2100-05-31")
start = Timestamp("2025-01-01")
end = Timestamp("2065-12-31")
exclude = DatetimeIndex(
[
Timestamp("2025-01-01"),
Expand All @@ -411,6 +423,52 @@ def test_holiday_with_multiple_exclusions():
assert ~exclude.isin(actual_dates).all()
assert actual_dates.isin(original_dates).all()

result = yakudoshi_new_year.dates(start, end)
expected = DatetimeIndex(
[
Timestamp("2026-01-01"),
Timestamp("2027-01-01"),
Timestamp("2028-01-01"),
Timestamp("2029-01-01"),
Timestamp("2030-01-01"),
Timestamp("2031-01-01"),
Timestamp("2032-01-01"),
Timestamp("2033-01-01"),
Timestamp("2034-01-01"),
Timestamp("2035-01-01"),
Timestamp("2036-01-01"),
Timestamp("2037-01-01"),
Timestamp("2038-01-01"),
Timestamp("2039-01-01"),
Timestamp("2040-01-01"),
Timestamp("2041-01-01"),
Timestamp("2043-01-01"),
Timestamp("2044-01-01"),
Timestamp("2045-01-01"),
Timestamp("2046-01-01"),
Timestamp("2047-01-01"),
Timestamp("2048-01-01"),
Timestamp("2049-01-01"),
Timestamp("2050-01-01"),
Timestamp("2051-01-01"),
Timestamp("2052-01-01"),
Timestamp("2053-01-01"),
Timestamp("2054-01-01"),
Timestamp("2055-01-01"),
Timestamp("2056-01-01"),
Timestamp("2057-01-01"),
Timestamp("2058-01-01"),
Timestamp("2059-01-01"),
Timestamp("2060-01-01"),
Timestamp("2062-01-01"),
Timestamp("2063-01-01"),
Timestamp("2064-01-01"),
Timestamp("2065-01-01"),
],
dtype="datetime64[ns]",
)
tm.assert_index_equal(result, expected)


def test_exclude_date_value_error():
msg = "exclude_dates must be None or of type DatetimeIndex."
Expand Down
Loading