diff --git a/pandas/util/_test_decorators.py b/pandas/util/_test_decorators.py index d8804994af426..b944ed48e2210 100644 --- a/pandas/util/_test_decorators.py +++ b/pandas/util/_test_decorators.py @@ -23,11 +23,13 @@ def test_foo(): For more information, refer to the ``pytest`` documentation on ``skipif``. """ + from distutils.version import LooseVersion from functools import wraps import locale from typing import Callable, Optional +from _pytest.mark.structures import MarkDecorator import numpy as np import pytest @@ -120,7 +122,7 @@ def _skip_if_no_scipy() -> bool: ) -def skip_if_installed(package: str) -> Callable: +def skip_if_installed(package: str) -> MarkDecorator: """ Skip a test if a package is installed. @@ -134,7 +136,7 @@ def skip_if_installed(package: str) -> Callable: ) -def skip_if_no(package: str, min_version: Optional[str] = None) -> Callable: +def skip_if_no(package: str, min_version: Optional[str] = None) -> MarkDecorator: """ Generic function to help skip tests when required packages are not present on the testing system. @@ -198,7 +200,7 @@ def skip_if_no(package: str, min_version: Optional[str] = None) -> Callable: def skip_if_np_lt( ver_str: str, reason: Optional[str] = None, *args, **kwds -) -> Callable: +) -> MarkDecorator: if reason is None: reason = f"NumPy {ver_str} or greater required" return pytest.mark.skipif( @@ -254,7 +256,7 @@ def new_func(*args, **kwargs): return new_func -def async_mark(): +def async_mark() -> MarkDecorator: try: import_optional_dependency("pytest_asyncio") async_mark = pytest.mark.asyncio