File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,29 @@ def _skip_if_not_us_locale():
95
95
96
96
97
97
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
+ """
98
121
def decorated_func (func ):
99
122
return pytest .mark .skipif (
100
123
not safe_import (package , min_version = min_version ),
You can’t perform that action at this time.
0 commit comments