Blob Blame History Raw
From 13bf54b1b6d37c7ed7bbfbd84f14235106806036 Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Fri, 15 Sep 2023 09:01:04 -0400
Subject: [PATCH] Replace PyPI mock test dependency with unittest.mock

The unittest.mock package is part of the standard library since Python 3.3.

See also: https://fedoraproject.org/wiki/Changes/DeprecatePythonMock
---
 doc/source/developer.rst       | 2 +-
 tests/apps/test_cli.py         | 2 +-
 tests/core/test_soma.py        | 2 +-
 tests/core/test_types.py       | 3 ++-
 tests/features/test_neurite.py | 2 +-
 tests/features/test_section.py | 1 -
 tests/view/test_plotly_impl.py | 4 ++--
 tox.ini                        | 1 -
 8 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/doc/source/developer.rst b/doc/source/developer.rst
index 8ebcbbff..b98ee33a 100644
--- a/doc/source/developer.rst
+++ b/doc/source/developer.rst
@@ -68,7 +68,7 @@ all required dependencies in your virtual environment:
 
 .. code-block:: bash
 
-    (your virtual env name)$ pip install neurom[plotly] pytest mock
+    (your virtual env name)$ pip install neurom[plotly] pytest
 
 Then, run the tests manually. For example,
 
diff --git a/tests/apps/test_cli.py b/tests/apps/test_cli.py
index 763ebb79..dbf616fe 100644
--- a/tests/apps/test_cli.py
+++ b/tests/apps/test_cli.py
@@ -5,7 +5,7 @@
 import pandas as pd
 import yaml
 from click.testing import CliRunner
-from mock import patch
+from unittest.mock import patch
 
 from neurom.apps.cli import cli
 from neurom.exceptions import ConfigError
diff --git a/tests/core/test_soma.py b/tests/core/test_soma.py
index aeeae238..71339e91 100644
--- a/tests/core/test_soma.py
+++ b/tests/core/test_soma.py
@@ -29,12 +29,12 @@
 import math
 import warnings
 from io import StringIO
+from unittest.mock import Mock
 
 import numpy as np
 from morphio import MorphioError, SomaError, set_raise_warnings
 from neurom import load_morphology
 from neurom.core import soma
-from mock import Mock
 
 import pytest
 from numpy.testing import assert_array_equal, assert_almost_equal
diff --git a/tests/core/test_types.py b/tests/core/test_types.py
index 5f80c7d7..e99449fa 100644
--- a/tests/core/test_types.py
+++ b/tests/core/test_types.py
@@ -27,7 +27,8 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-from mock import Mock
+from unittest.mock import Mock
+
 from neurom.core.types import NEURITES, NeuriteType, axon_filter, dendrite_filter, tree_type_checker
 import pytest
 
diff --git a/tests/features/test_neurite.py b/tests/features/test_neurite.py
index 90bea2a3..1f476d89 100644
--- a/tests/features/test_neurite.py
+++ b/tests/features/test_neurite.py
@@ -30,11 +30,11 @@
 
 from math import pi, sqrt
 from pathlib import Path
+from unittest.mock import patch
 
 import neurom as nm
 import numpy as np
 import scipy
-from mock import patch
 from neurom.features import neurite, morphology
 from neurom.geom import convex_hull
 
diff --git a/tests/features/test_section.py b/tests/features/test_section.py
index 6afb6def..373d32a5 100644
--- a/tests/features/test_section.py
+++ b/tests/features/test_section.py
@@ -37,7 +37,6 @@
 import pytest
 import numpy as np
 from numpy import testing as npt
-from mock import Mock
 
 from neurom import load_morphology, iter_sections
 from neurom import morphmath
diff --git a/tests/view/test_plotly_impl.py b/tests/view/test_plotly_impl.py
index ba58d862..4523c9f7 100644
--- a/tests/view/test_plotly_impl.py
+++ b/tests/view/test_plotly_impl.py
@@ -1,11 +1,11 @@
 import sys
 from pathlib import Path
+from unittest.mock import patch
 
 import neurom
 from neurom import load_morphology
 from neurom.view import plotly_impl
 
-import mock
 from numpy.testing import assert_allclose
 
 SWC_PATH = Path(__file__).parent.parent / 'data/swc'
@@ -20,7 +20,7 @@ def _reload_module(module):
 
 
 def test_plotly_extra_not_installed():
-    with mock.patch.dict(sys.modules, {'plotly': None}):
+    with patch.dict(sys.modules, {'plotly': None}):
         try:
             _reload_module(neurom.view.plotly_impl)
             assert False, "ImportError not triggered"
diff --git a/tox.ini b/tox.ini
index 1a0cded1..41a887b3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,6 @@
 [base]
 name = neurom
 testdeps =
-    mock
     pytest>3.0
 
 [tox]