Skip to content

Commit c05c499

Browse files
committed
TEST: Move from mock to unittest.mock
1 parent 54951c0 commit c05c499

11 files changed

+9
-24
lines changed

dev-requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# Requirements for running tests
22
-r requirements.txt
33
nose
4-
mock

doc-requirements.txt

-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ sphinx
44
numpydoc
55
texext
66
matplotlib>=1.3
7-
mock

doc/source/installation.rst

-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ Requirements
8989
* PyDICOM_ 0.9.9 or greater (optional, for DICOM support)
9090
* `Python Imaging Library`_ (optional, for PNG conversion in DICOMFS)
9191
* nose_ 0.11 or greater (optional, to run the tests)
92-
* mock_ (optional, to run the tests)
9392
* sphinx_ (optional, to build the documentation)
9493

9594
Get the development sources

doc/source/links_names.txt

-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
.. _emacs_python_mode: http://www.emacswiki.org/cgi-bin/wiki/PythonMode
8484
.. _doctest-mode: http://ed.loper.org/projects/doctestmode/
8585
.. _nose: http://somethingaboutorange.com/mrl/projects/nose
86-
.. _mock: https://github.com/testing-cabal/mock
8786
.. _`python coverage tester`: http://nedbatchelder.com/code/coverage/
8887
.. _bitbucket: https://bitbucket.org
8988
.. _six: http://pythonhosted.org/six

nibabel/__init__.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,10 @@ def teardown_package():
9292
from . import streamlines
9393
from . import viewers
9494

95-
import pkgutil
96-
97-
if not pkgutil.find_loader('mock'):
98-
def test(*args, **kwargs):
99-
raise RuntimeError('Need "mock" package for tests')
100-
else:
101-
from numpy.testing import Tester
102-
test = Tester().test
103-
bench = Tester().bench
104-
del Tester
105-
106-
del pkgutil
95+
from numpy.testing import Tester
96+
test = Tester().test
97+
bench = Tester().bench
98+
del Tester
10799

108100
from .pkg_info import get_pkg_info as _get_pkg_info
109101

nibabel/benchmarks/bench_arrayproxy_slicing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import gc
1919
import itertools as it
2020
import numpy as np
21-
import mock
21+
from unittest import mock
2222

2323
import nibabel as nib
2424
from nibabel.tmpdirs import InTemporaryDirectory

nibabel/cmdline/tests/test_parrec2nii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import nibabel
99
from nibabel.cmdline import parrec2nii
1010

11-
from mock import Mock, MagicMock, patch
11+
from unittest.mock import Mock, MagicMock, patch
1212
from nose.tools import assert_true
1313
from numpy.testing import (assert_almost_equal, assert_array_equal)
1414

nibabel/tests/test_arrayproxy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ..openers import ImageOpener
2424
from ..nifti1 import Nifti1Header
2525

26-
import mock
26+
from unittest import mock
2727

2828
from numpy.testing import assert_array_equal, assert_array_almost_equal
2929
from nose.tools import (assert_true, assert_false, assert_equal,

nibabel/tests/test_openers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from ..tmpdirs import InTemporaryDirectory
1919
from ..volumeutils import BinOpener
2020

21-
import mock
21+
from unittest import mock
2222
from nose.tools import (assert_true, assert_false, assert_equal,
2323
assert_not_equal, assert_raises)
2424
from ..testing import error_warnings

nibabel/tests/test_optpkg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" Testing optpkg module
22
"""
33

4-
import mock
4+
from unittest import mock
55
import types
66
import sys
77
import builtins

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ install_requires =
3434
tests_require =
3535
nose >=0.11
3636
pytest
37-
mock
3837
test_suite = nose.collector
3938
zip_safe = False
4039
packages = find:
@@ -47,15 +46,13 @@ dev =
4746
twine
4847
doc =
4948
matplotlib >= 1.3.1
50-
mock
5149
numpydoc
5250
sphinx >=0.3
5351
texext
5452
style =
5553
flake8
5654
test =
5755
coverage
58-
mock
5956
nose >=0.11
6057
pytest
6158
all =

0 commit comments

Comments
 (0)