@@ -359,7 +359,7 @@ def test_holiday_with_exclusion():
359
359
# GH 54382
360
360
start = Timestamp ("2020-05-01" )
361
361
end = Timestamp ("2025-05-31" )
362
- exclude = [Timestamp ("2022-05-30" )] # Queen's platinum Jubilee
362
+ exclude = DatetimeIndex ( [Timestamp ("2022-05-30" )]) # Queen's platinum Jubilee
363
363
default_uk_spring_bank_holiday : Holiday = Holiday (
364
364
"UK Spring Bank Holiday" ,
365
365
month = 5 ,
@@ -375,22 +375,25 @@ def test_holiday_with_exclusion():
375
375
exclude_dates = exclude ,
376
376
)
377
377
378
- original_dates = list (default_uk_spring_bank_holiday .dates (start , end ))
379
- exclusion_dates = list (queens_jubilee_uk_spring_bank_holiday .dates (start , end ))
378
+ original_dates = default_uk_spring_bank_holiday .dates (start , end )
379
+ actual_dates = queens_jubilee_uk_spring_bank_holiday .dates (start , end )
380
+ print (exclude .isin (original_dates ).all ())
380
381
381
- assert all ( ex in original_dates for ex in exclude )
382
- assert all (ex not in exclusion_dates for ex in exclude )
383
- assert set ( exclusion_dates ). issubset ( original_dates )
382
+ assert exclude . isin ( original_dates ). all ( )
383
+ assert ~ exclude . isin ( actual_dates ). all ()
384
+ assert actual_dates . isin ( original_dates ). all ( )
384
385
385
386
386
387
def test_holiday_with_multiple_exclusions ():
387
388
start = Timestamp ("2000-01-01" )
388
389
end = Timestamp ("2100-05-31" )
389
- exclude = [
390
- Timestamp ("2025-01-01" ),
391
- Timestamp ("2042-01-01" ),
392
- Timestamp ("2061-01-01" ),
393
- ] # Yakudoshi new year
390
+ exclude = DatetimeIndex (
391
+ [
392
+ Timestamp ("2025-01-01" ),
393
+ Timestamp ("2042-01-01" ),
394
+ Timestamp ("2061-01-01" ),
395
+ ]
396
+ ) # Yakudoshi new year
394
397
default_japan_new_year : Holiday = Holiday (
395
398
"Japan New Year" ,
396
399
month = 1 ,
@@ -401,9 +404,20 @@ def test_holiday_with_multiple_exclusions():
401
404
"Yakudoshi New Year" , month = 1 , day = 1 , exclude_dates = exclude
402
405
)
403
406
404
- original_dates = list (default_japan_new_year .dates (start , end ))
405
- exclusion_dates = list (yakudoshi_new_year .dates (start , end ))
407
+ original_dates = default_japan_new_year .dates (start , end )
408
+ actual_dates = yakudoshi_new_year .dates (start , end )
409
+
410
+ assert exclude .isin (original_dates ).all ()
411
+ assert ~ exclude .isin (actual_dates ).all ()
412
+ assert actual_dates .isin (original_dates ).all ()
413
+
406
414
407
- assert all (ex in original_dates for ex in exclude )
408
- assert all (ex not in exclusion_dates for ex in exclude )
409
- assert set (exclusion_dates ).issubset (original_dates )
415
+ def test_exclude_date_value_error ():
416
+ msg = "exclude_dates must be None or of type DatetimeIndex."
417
+
418
+ with pytest .raises (ValueError , match = msg ):
419
+ exclude = [
420
+ Timestamp ("2025-06-10" ),
421
+ Timestamp ("2026-06-10" ),
422
+ ]
423
+ Holiday ("National Ice Tea Day" , month = 6 , day = 10 , exclude_dates = exclude )
0 commit comments