Skip to content

TST: Reorganize package_check and skip_if_no_package #15709

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

Merged
merged 1 commit into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion pandas/tests/io/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,8 @@ def test_put_compression(self):
format='fixed', complib='zlib')

def test_put_compression_blosc(self):
tm.skip_if_no_package('tables', '2.2', app='blosc support')
tm.skip_if_no_package('tables', min_version='2.2',
app='blosc support')
if skip_compression:
pytest.skip("skipping on windows/PY3")

Expand Down
27 changes: 10 additions & 17 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2010,12 +2010,16 @@ def __init__(self, *args, **kwargs):
dict.__init__(self, *args, **kwargs)


# Dependency checks. Copied this from Nipy/Nipype (Copyright of
# respective developers, license: BSD-3)
def package_check(pkg_name, min_version=None, max_version=None, app='pandas',
checker=LooseVersion):
# Dependency checker when running tests.
#
# Copied this from nipy/nipype
# Copyright of respective developers, License: BSD-3
def skip_if_no_package(pkg_name, min_version=None, max_version=None,
app='pandas', checker=LooseVersion):
"""Check that the min/max version of the required package is installed.

If the package check fails, the test is automatically skipped.

Parameters
----------
pkg_name : string
Expand All @@ -2025,11 +2029,11 @@ def package_check(pkg_name, min_version=None, max_version=None, app='pandas',
max_version : string, optional
Max version number for required package.
app : string, optional
Application that is performing the check. For instance, the
Application that is performing the check. For instance, the
name of the tutorial being executed that depends on specific
packages.
checker : object, optional
The class that will perform the version checking. Default is
The class that will perform the version checking. Default is
distutils.version.LooseVersion.

Examples
Expand Down Expand Up @@ -2061,17 +2065,6 @@ def package_check(pkg_name, min_version=None, max_version=None, app='pandas',
pytest.skip(msg)


def skip_if_no_package(*args, **kwargs):
"""pytest.skip() if package_check fails

Parameters
----------
*args Positional parameters passed to `package_check`
*kwargs Keyword parameters passed to `package_check`
"""
package_check(*args, **kwargs)


def optional_args(decorator):
"""allows a decorator to take optional positional and keyword arguments.
Assumes that taking a single, callable, positional argument means that
Expand Down