Skip to content

Commit

Permalink
split test for diffent python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil Smorchkov authored and Danil Smorchkov committed Feb 10, 2025
1 parent 2f54a53 commit 7c2ae24
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion tests/test_transforms/test_timestamp/test_holiday_transform.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from typing import Optional

import numpy as np
Expand Down Expand Up @@ -401,6 +402,7 @@ def test_transform_category_day(in_column, ts_name, iso_code, answer, request):
assert df[segment]["holiday"].dtype == "category"


@pytest.mark.skipif(sys.version_info.minor < 12, reason="In Python 3.12 Russian holidays are called in Russian")
@pytest.mark.parametrize(
"iso_code,answer",
(
Expand All @@ -424,7 +426,39 @@ def test_transform_category_day(in_column, ts_name, iso_code, answer, request):
),
),
)
def test_transform_category_w_mon(iso_code: str, answer: np.array, two_segments_w_mon):
def test_transform_category_w_mon_python_10(iso_code: str, answer: np.array, two_segments_w_mon):
holidays_finder = HolidayTransform(iso_code=iso_code, mode="category", out_column="holiday")
df = holidays_finder.fit_transform(two_segments_w_mon).to_pandas()
for segment in df.columns.get_level_values("segment").unique():
assert np.array_equal(df[segment]["holiday"].to_numpy(), answer)
assert df[segment]["holiday"].dtype == "category"


@pytest.mark.skipif(sys.version_info.minor >= 12, reason="In Python 3.12 Russian holidays are called in Russian")
@pytest.mark.parametrize(
"iso_code,answer",
(
(
"RUS",
np.array(
["NO_HOLIDAY"] * 6
+ ["Выходной (перенесено с 23.02.2020)", "NO_HOLIDAY", "Выходной (перенесено с 08.03.2020)"]
+ ["NO_HOLIDAY"] * 7
+ ["Выходной (перенесено с 04.01.2020)", "Выходной (перенесено с 09.05.2020)"]
),
),
(
"US",
np.array(
["NO_HOLIDAY", "Martin Luther King Jr. Day"]
+ ["NO_HOLIDAY"] * 3
+ ["Washington's Birthday"]
+ ["NO_HOLIDAY"] * 12
),
),
),
)
def test_transform_category_w_mon_python_12(iso_code: str, answer: np.array, two_segments_w_mon):
holidays_finder = HolidayTransform(iso_code=iso_code, mode="category", out_column="holiday")
df = holidays_finder.fit_transform(two_segments_w_mon).to_pandas()
for segment in df.columns.get_level_values("segment").unique():
Expand Down

0 comments on commit 7c2ae24

Please sign in to comment.