|
15 | 15 | from datetime import datetime
|
16 | 16 | from functools import wraps, partial
|
17 | 17 | from contextlib import contextmanager
|
18 |
| -from distutils.version import LooseVersion |
19 | 18 |
|
20 | 19 | from numpy.random import randn, rand
|
21 | 20 | import numpy as np
|
@@ -317,35 +316,6 @@ def close(fignum=None):
|
317 | 316 | _close(fignum)
|
318 | 317 |
|
319 | 318 |
|
320 |
| -def _skip_if_mpl_1_5(): |
321 |
| - import matplotlib as mpl |
322 |
| - |
323 |
| - v = mpl.__version__ |
324 |
| - if LooseVersion(v) > LooseVersion('1.4.3') or str(v)[0] == '0': |
325 |
| - import pytest |
326 |
| - pytest.skip("matplotlib 1.5") |
327 |
| - else: |
328 |
| - mpl.use("Agg", warn=False) |
329 |
| - |
330 |
| - |
331 |
| -def _skip_if_no_scipy(): |
332 |
| - import pytest |
333 |
| - |
334 |
| - pytest.importorskip("scipy.stats") |
335 |
| - pytest.importorskip("scipy.sparse") |
336 |
| - pytest.importorskip("scipy.interpolate") |
337 |
| - |
338 |
| - |
339 |
| -def _skip_if_no_mock(): |
340 |
| - try: |
341 |
| - import mock # noqa |
342 |
| - except ImportError: |
343 |
| - try: |
344 |
| - from unittest import mock # noqa |
345 |
| - except ImportError: |
346 |
| - import pytest |
347 |
| - raise pytest.skip("mock is not installed") |
348 |
| - |
349 | 319 | # -----------------------------------------------------------------------------
|
350 | 320 | # locale utilities
|
351 | 321 |
|
@@ -1979,62 +1949,6 @@ def __init__(self, *args, **kwargs):
|
1979 | 1949 | dict.__init__(self, *args, **kwargs)
|
1980 | 1950 |
|
1981 | 1951 |
|
1982 |
| -# Dependency checker when running tests. |
1983 |
| -# |
1984 |
| -# Copied this from nipy/nipype |
1985 |
| -# Copyright of respective developers, License: BSD-3 |
1986 |
| -def skip_if_no_package(pkg_name, min_version=None, max_version=None, |
1987 |
| - app='pandas', checker=LooseVersion): |
1988 |
| - """Check that the min/max version of the required package is installed. |
1989 |
| -
|
1990 |
| - If the package check fails, the test is automatically skipped. |
1991 |
| -
|
1992 |
| - Parameters |
1993 |
| - ---------- |
1994 |
| - pkg_name : string |
1995 |
| - Name of the required package. |
1996 |
| - min_version : string, optional |
1997 |
| - Minimal version number for required package. |
1998 |
| - max_version : string, optional |
1999 |
| - Max version number for required package. |
2000 |
| - app : string, optional |
2001 |
| - Application that is performing the check. For instance, the |
2002 |
| - name of the tutorial being executed that depends on specific |
2003 |
| - packages. |
2004 |
| - checker : object, optional |
2005 |
| - The class that will perform the version checking. Default is |
2006 |
| - distutils.version.LooseVersion. |
2007 |
| -
|
2008 |
| - Examples |
2009 |
| - -------- |
2010 |
| - package_check('numpy', '1.3') |
2011 |
| -
|
2012 |
| - """ |
2013 |
| - |
2014 |
| - import pytest |
2015 |
| - if app: |
2016 |
| - msg = '{app} requires {pkg_name}'.format(app=app, pkg_name=pkg_name) |
2017 |
| - else: |
2018 |
| - msg = 'module requires {pkg_name}'.format(pkg_name=pkg_name) |
2019 |
| - if min_version: |
2020 |
| - msg += ' with version >= {min_version}'.format(min_version=min_version) |
2021 |
| - if max_version: |
2022 |
| - msg += ' with version < {max_version}'.format(max_version=max_version) |
2023 |
| - try: |
2024 |
| - mod = __import__(pkg_name) |
2025 |
| - except ImportError: |
2026 |
| - mod = None |
2027 |
| - try: |
2028 |
| - have_version = mod.__version__ |
2029 |
| - except AttributeError: |
2030 |
| - pytest.skip('Cannot find version for {pkg_name}' |
2031 |
| - .format(pkg_name=pkg_name)) |
2032 |
| - if min_version and checker(have_version) < checker(min_version): |
2033 |
| - pytest.skip(msg) |
2034 |
| - if max_version and checker(have_version) >= checker(max_version): |
2035 |
| - pytest.skip(msg) |
2036 |
| - |
2037 |
| - |
2038 | 1952 | def optional_args(decorator):
|
2039 | 1953 | """allows a decorator to take optional positional and keyword arguments.
|
2040 | 1954 | Assumes that taking a single, callable, positional argument means that
|
|
0 commit comments