Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Make skip_requires_pyarrow compatible w/ pytest.param #3772

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
import sys
from importlib.util import find_spec
from pathlib import Path
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, overload

import pytest

from tests import examples_arguments_syntax, examples_methods_syntax

if TYPE_CHECKING:
from collections.abc import Callable, Collection, Iterator, Mapping
from collections.abc import Collection, Iterator, Mapping
from re import Pattern

if sys.version_info >= (3, 11):
from typing import TypeAlias
else:
from typing_extensions import TypeAlias
from _pytest.mark import ParameterSet
from _pytest.mark.structures import Markable

MarksType: TypeAlias = (
"pytest.MarkDecorator | Collection[pytest.MarkDecorator | pytest.Mark]"
Expand Down Expand Up @@ -96,9 +97,21 @@ def windows_has_tzdata() -> bool:
"""


@overload
def skip_requires_pyarrow(
fn: Callable[..., Any] | None = None, /, *, requires_tzdata: bool = False
) -> Callable[..., Any]:
fn: None = ..., /, *, requires_tzdata: bool = ...
) -> pytest.MarkDecorator: ...


@overload
def skip_requires_pyarrow(
fn: Markable, /, *, requires_tzdata: bool = ...
) -> Markable: ...


def skip_requires_pyarrow(
fn: Markable | None = None, /, *, requires_tzdata: bool = False
) -> pytest.MarkDecorator | Markable:
"""
``pytest.mark.skipif`` decorator.

Expand All @@ -109,7 +122,7 @@ def skip_requires_pyarrow(
https://github.com/vega/altair/issues/3050

.. _pyarrow:
https://pypi.org/project/pyarrow/
https://pypi.org/project/pyarrow/
"""
composed = pytest.mark.skipif(
find_spec("pyarrow") is None, reason="`pyarrow` not installed."
Expand All @@ -120,13 +133,7 @@ def skip_requires_pyarrow(
reason="Timezone database is not installed on Windows",
)(composed)

def wrap(test_fn: Callable[..., Any], /) -> Callable[..., Any]:
return composed(test_fn)

if fn is None:
return wrap
else:
return wrap(fn)
return composed if fn is None else composed(fn)


def id_func_str_only(val) -> str:
Expand Down
Loading