Skip to content

Commit 53d5737

Browse files
committed
Added docstring to skip_if_no function
1 parent 4500f98 commit 53d5737

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

pandas/util/_test_decorators.py

+23
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,29 @@ def _skip_if_not_us_locale():
9595

9696

9797
def skip_if_no(package, min_version=None):
98+
"""
99+
Generic function to help skip test functions when required packages are not
100+
present on the testing system.
101+
102+
Intended for use as a decorator, this function will wrap the decorated
103+
function with a pytest ``skip_if`` mark. During a pytest test suite
104+
execution, that mark will attempt to import the specified ``package`` and
105+
optionally ensure it meets the ``min_version``. If the import and version
106+
check are unsuccessful, then the decorated function will be skipped.
107+
108+
Parameters
109+
----------
110+
package: str
111+
The name of the package required by the decorated function
112+
min_version: str or None, default None
113+
Optional minimum version of the package required by the decorated
114+
function
115+
116+
Returns
117+
-------
118+
decorated_func: function
119+
The decorated function wrapped within a pytest ``skip_if`` mark
120+
"""
98121
def decorated_func(func):
99122
return pytest.mark.skipif(
100123
not safe_import(package, min_version=min_version),

0 commit comments

Comments
 (0)