Skip to content

Commit b5b34c7

Browse files
committed
RF: Use pkgutil to avoid importing nose
1 parent 58356c5 commit b5b34c7

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

nibabel/optpkg.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
""" Routines to support optional packages """
2+
import pkgutil
23
from distutils.version import LooseVersion
3-
44
from six import string_types
5+
from .tripwire import TripWire
56

6-
try:
7-
import nose
8-
except ImportError:
9-
have_nose = False
10-
else:
7+
if pkgutil.find_loader('nose'):
118
have_nose = True
12-
13-
from .tripwire import TripWire
9+
else:
10+
have_nose = False
1411

1512

1613
def _check_pkg_version(pkg, min_version):
@@ -121,6 +118,7 @@ def optional_package(name, trip_msg=None, min_version=None):
121118

122119
def setup_module():
123120
if have_nose:
121+
import nose
124122
raise nose.plugins.skip.SkipTest('No %s for these tests'
125123
% name)
126124
return pkg, False, setup_module

0 commit comments

Comments
 (0)