Skip to content

Commit c9c67a8

Browse files
committed
RF: Check for mock using pkgutil
1 parent b5b34c7 commit c9c67a8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

nibabel/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,18 @@ def setup_test():
8080
from . import streamlines
8181
from . import viewers
8282

83-
# Note test requirement for "mock". Requirement for "nose" tested by numpy.
84-
try:
85-
import mock
86-
except ImportError:
83+
import pkgutil
84+
85+
if not pkgutil.find_loader('mock'):
8786
def test(*args, **kwargs):
8887
raise RuntimeError('Need "mock" package for tests')
8988
else:
9089
from numpy.testing import Tester
9190
test = Tester().test
9291
bench = Tester().bench
93-
del mock, Tester
92+
del Tester
93+
94+
del pkgutil
9495

9596
from .pkg_info import get_pkg_info as _get_pkg_info
9697

0 commit comments

Comments
 (0)