diff --git a/tests/expr/test_dt.py b/tests/expr/test_dt.py index 8cfd5d3f0..efec288c4 100644 --- a/tests/expr/test_dt.py +++ b/tests/expr/test_dt.py @@ -1,6 +1,5 @@ from __future__ import annotations -import sys from datetime import datetime from datetime import timedelta from typing import Any @@ -16,6 +15,7 @@ import narwhals as nw from narwhals.utils import parse_version from tests.utils import compare_dicts +from tests.utils import is_windows data = { "a": [ @@ -174,10 +174,7 @@ def test_total_minutes(timedeltas: timedelta) -> None: @pytest.mark.parametrize( "fmt", ["%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%Y/%m/%d %H:%M:%S", "%G-W%V-%u", "%G-W%V"] ) -@pytest.mark.skipif( - "win" in sys.platform, - reason="pyarrow breaking on windows", -) +@pytest.mark.skipif(is_windows(), reason="pyarrow breaking on windows") def test_dt_to_string(constructor: Any, fmt: str) -> None: input_frame = nw.from_native(constructor(data), eager_only=True) input_series = input_frame["a"] @@ -208,10 +205,7 @@ def test_dt_to_string(constructor: Any, fmt: str) -> None: (datetime(2020, 1, 9, 12, 34, 56, 123456), "2020-01-09T12:34:56.123456"), ], ) -@pytest.mark.skipif( - "win" in sys.platform, - reason="pyarrow breaking on windows", -) +@pytest.mark.skipif(is_windows(), reason="pyarrow breaking on windows") def test_dt_to_string_iso_local_datetime( constructor: Any, data: datetime, expected: str ) -> None: @@ -259,10 +253,7 @@ def _clean_string(result: str) -> str: (datetime(2020, 1, 9), "2020-01-09"), ], ) -@pytest.mark.skipif( - "win" in sys.platform, - reason="pyarrow breaking on windows", -) +@pytest.mark.skipif(is_windows(), reason="pyarrow breaking on windows") def test_dt_to_string_iso_local_date( constructor: Any, data: datetime, expected: str ) -> None: diff --git a/tests/utils.py b/tests/utils.py index b969fd76d..83bf016a5 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -2,6 +2,7 @@ import math import os +import sys import warnings from typing import TYPE_CHECKING from typing import Any @@ -53,3 +54,8 @@ def maybe_get_modin_df(df_pandas: pd.DataFrame) -> Any: return mpd.DataFrame(df_pandas.to_dict(orient="list")) else: # pragma: no cover return df_pandas + + +def is_windows() -> bool: + """Check if the current platform is Windows.""" + return sys.platform in ["win32", "cygwin"]