diff --git a/ci/deps/actions-310.yaml b/ci/deps/actions-310.yaml index dac1219245e84..369d27b8c97b9 100644 --- a/ci/deps/actions-310.yaml +++ b/ci/deps/actions-310.yaml @@ -9,7 +9,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -27,6 +26,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml diff --git a/ci/deps/actions-38-downstream_compat.yaml b/ci/deps/actions-38-downstream_compat.yaml index 629d7b501692d..946e86bf62674 100644 --- a/ci/deps/actions-38-downstream_compat.yaml +++ b/ci/deps/actions-38-downstream_compat.yaml @@ -10,7 +10,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -28,6 +27,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml diff --git a/ci/deps/actions-38-minimum_versions.yaml b/ci/deps/actions-38-minimum_versions.yaml index f3a967f67cbc3..99f8b89d1d562 100644 --- a/ci/deps/actions-38-minimum_versions.yaml +++ b/ci/deps/actions-38-minimum_versions.yaml @@ -11,7 +11,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -29,6 +28,7 @@ dependencies: - fastparquet=0.4.0 - fsspec=0.7.4 - html5lib=1.1 + - hypothesis=5.5.3 - gcsfs=0.6.0 - jinja2=2.11 - lxml=4.5.0 diff --git a/ci/deps/actions-38.yaml b/ci/deps/actions-38.yaml index 79cd831051c2f..2b07d5f9e89a7 100644 --- a/ci/deps/actions-38.yaml +++ b/ci/deps/actions-38.yaml @@ -9,7 +9,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -27,6 +26,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml diff --git a/ci/deps/actions-39.yaml b/ci/deps/actions-39.yaml index 1c681104f3196..de726e105a8f8 100644 --- a/ci/deps/actions-39.yaml +++ b/ci/deps/actions-39.yaml @@ -9,7 +9,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -27,6 +26,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml diff --git a/ci/deps/circle-38-arm64.yaml b/ci/deps/circle-38-arm64.yaml index 66fedccc5eca7..0f57dc8058086 100644 --- a/ci/deps/circle-38-arm64.yaml +++ b/ci/deps/circle-38-arm64.yaml @@ -9,7 +9,6 @@ dependencies: - pytest>=6.0 - pytest-cov - pytest-xdist>=1.31 - - hypothesis>=5.5.3 - psutil - pytest-asyncio>=0.17 - boto3 @@ -27,6 +26,7 @@ dependencies: - fastparquet - fsspec - html5lib + - hypothesis - gcsfs - jinja2 - lxml diff --git a/pandas/compat/_optional.py b/pandas/compat/_optional.py index e69bee5c647d8..43134c3ab01d5 100644 --- a/pandas/compat/_optional.py +++ b/pandas/compat/_optional.py @@ -17,6 +17,7 @@ "fastparquet": "0.4.0", "fsspec": "0.7.4", "html5lib": "1.1", + "hypothesis": "5.5.3", "gcsfs": "0.6.0", "jinja2": "2.11", "lxml.etree": "4.5.0", diff --git a/pandas/util/_tester.py b/pandas/util/_tester.py index 6725a84aee962..1b018a6a1ba34 100644 --- a/pandas/util/_tester.py +++ b/pandas/util/_tester.py @@ -1,24 +1,29 @@ """ Entrypoint for testing from the top-level namespace. """ +from __future__ import annotations + import os import sys +from pandas.compat._optional import import_optional_dependency + PKG = os.path.dirname(os.path.dirname(__file__)) -def test(extra_args=None): +def test(extra_args: list[str] | None = None): """ Run the pandas test suite using pytest. + + By default, runs with the marks --skip-slow, --skip-network, --skip-db + + Parameters + ---------- + extra_args : list[str], default None + Extra marks to run the tests. """ - try: - import pytest - except ImportError as err: - raise ImportError("Need pytest>=5.0.1 to run tests") from err - try: - import hypothesis # noqa:F401 - except ImportError as err: - raise ImportError("Need hypothesis>=3.58 to run tests") from err + pytest = import_optional_dependency("pytest") + import_optional_dependency("hypothesis") cmd = ["--skip-slow", "--skip-network", "--skip-db"] if extra_args: if not isinstance(extra_args, list):