Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7657f82

Browse files
committed
Mock is in stdlib in Py3.
so don't rely on the 3rd party version. Also replace py.test by pytest in the docs (recommended since pytest 3.0, https://docs.pytest.org/en/latest/changelog.html#id281; we require pytest>=3.1 anyways). Also delete tox.ini which is clearly outdated.
1 parent 072dd2b commit 7657f82

20 files changed

+39
-103
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ install:
5959
#
6060
- conda create -q -n test-environment python=%PYTHON_VERSION%
6161
msinttypes freetype=2.6 "libpng>=1.6.21,<1.7" zlib=1.2 tk=8.5
62-
pip setuptools numpy mock pandas sphinx tornado
62+
pip setuptools numpy pandas sphinx tornado
6363
- activate test-environment
6464
- echo %PYTHON_VERSION% %TARGET_ARCH%
6565
# pytest-cov>=2.3.1 due to https://github.com/pytest-dev/pytest-cov/issues/124

.travis.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ env:
4848
- secure: "dfjNqGKzQG5bu3FnDNwLG8H/C4QoieFo4PfFmZPdM2RY7WIzukwKFNT6kiDfOrpwt+2bR7FhzjOGlDECGtlGOtYPN8XuXGjhcP4a4IfakdbDfF+D3NPIpf5VlE6776k0VpvcZBTMYJKNFIMc7QPkOwjvNJ2aXyfe3hBuGlKJzQU="
4949
- CYCLER=cycler
5050
- DATEUTIL=python-dateutil
51-
- MOCK=
5251
- NOSE=
5352
- NUMPY=numpy
5453
- PANDAS=
@@ -71,7 +70,6 @@ matrix:
7170
env:
7271
- CYCLER=cycler==0.10
7372
- DATEUTIL=python-dateutil==2.1
74-
- MOCK=mock
7573
- NOSE=nose
7674
- NUMPY=numpy==1.10.0
7775
- PANDAS='pandas<0.21.0'
@@ -87,7 +85,6 @@ matrix:
8785
env: PRE=--pre
8886
- os: osx
8987
language: generic # https://github.com/travis-ci/travis-ci/issues/2312
90-
env: MOCK=mock
9188
only: master
9289
cache:
9390
# As for now travis caches only "$HOME/.cache/pip"
@@ -123,21 +120,18 @@ before_install:
123120
fi
124121
125122
install:
126-
# Upgrade pip and setuptools. Mock has issues with the default version of
127-
# setuptools
128123
- |
129-
# Setup environment
124+
# Setup environment.
130125
ccache -s
131126
git describe
132-
# Upgrade pip and setuptools and wheel to get as clean an install as possible
127+
# Upgrade pip and setuptools and wheel to get as clean an install as possible.
133128
python -mpip install --upgrade pip setuptools wheel
134129
- |
135-
# Install dependencies from PyPI
130+
# Install dependencies from PyPI.
136131
python -mpip install --upgrade $PRE \
137132
codecov \
138133
coverage \
139134
$CYCLER \
140-
$MOCK \
141135
$NOSE \
142136
$NUMPY \
143137
$PANDAS \

INSTALL.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ To run the test suite:
5454
* extract the :file:`lib\\matplotlib\\tests` or
5555
:file:`lib\\mpl_toolkits\\tests` directories from the source distribution;
5656
* install test dependencies: `pytest <https://pypi.python.org/pypi/pytest>`_,
57-
`mock <https://pypi.python.org/pypi/mock>`_, Pillow, MiKTeX, GhostScript,
58-
ffmpeg, avconv, ImageMagick, and `Inkscape <https://inkscape.org/>`_;
59-
* run ``py.test path\to\tests\directory``.
57+
Pillow, MiKTeX, GhostScript, ffmpeg, avconv, ImageMagick, and `Inkscape
58+
<https://inkscape.org/>`_;
59+
* run ``pytest path\to\tests\directory``.
6060

6161

6262
Third-party distributions of Matplotlib

README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ Testing
5252

5353
After installation, you can launch the test suite::
5454

55-
py.test
55+
pytest
5656

5757
Or from the Python interpreter::
5858

5959
import matplotlib
6060
matplotlib.test()
6161

62-
Consider reading http://matplotlib.org/devel/coding_guide.html#testing for
63-
more information. Note that the test suite requires pytest and, on Python 2.7,
64-
mock. Please install with pip or your package manager of choice.
62+
Consider reading http://matplotlib.org/devel/coding_guide.html#testing for more
63+
information. Note that the test suite requires pytest. Please install with pip
64+
or your package manager of choice.
6565

6666
Contact
6767
=======

doc-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ sphinx>=1.3,!=1.5.0,!=1.6.4
1010
colorspacious
1111
ipython
1212
ipywidgets
13-
mock
1413
numpydoc>=0.4
1514
pillow
1615
sphinx-gallery>=0.1.12

doc/conf.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ def _check_deps():
5858
"numpydoc": 'numpydoc',
5959
"PIL.Image": 'pillow',
6060
"sphinx_gallery": 'sphinx_gallery'}
61-
if sys.version_info < (3, 3):
62-
names["mock"] = 'mock'
6361
missing = []
6462
for name in names:
6563
try:

doc/devel/contributing.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,17 @@ Additionally you will need to copy :file:`setup.cfg.template` to
142142
In either case you can then run the tests to check your work
143143
environment is set up properly::
144144

145-
python tests.py
145+
pytest
146146

147147
.. _pytest: http://doc.pytest.org/en/latest/
148148
.. _pep8: https://pep8.readthedocs.io/en/latest/
149-
.. _mock: https://docs.python.org/dev/library/unittest.mock.html
150149
.. _Ghostscript: https://www.ghostscript.com/
151150
.. _Inkscape: https://inkscape.org>
152151

153152
.. note::
154153

155154
**Additional dependencies for testing**: pytest_ (version 3.1 or later),
156-
mock_ (if Python 2), Ghostscript_, Inkscape_
155+
Ghostscript_, Inkscape_
157156

158157
.. seealso::
159158

doc/devel/documenting_mpl.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ requirements that are needed to build the documentation. They are listed in
4545
* Sphinx>=1.3, !=1.5.0, !=1.6.4
4646
* colorspacious
4747
* IPython
48-
* mock
4948
* numpydoc>=0.4
5049
* Pillow
5150
* sphinx-gallery>=0.1.12

doc/devel/testing.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Matplotlib's testing infrastructure depends on pytest_. The tests are in
99
infrastructure are in :mod:`matplotlib.testing`.
1010

1111
.. _pytest: http://doc.pytest.org/en/latest/
12-
.. _mock: https://docs.python.org/3/library/unittest.mock.html
1312
.. _Ghostscript: https://www.ghostscript.com/
1413
.. _Inkscape: https://inkscape.org
1514
.. _pytest-cov: https://pytest-cov.readthedocs.io/en/latest/
@@ -27,7 +26,6 @@ local FreeType build
2726
The following software is required to run the tests:
2827

2928
- pytest_ (>=3.1)
30-
- mock_, when running Python 2
3129
- Ghostscript_ (to render PDF files)
3230
- Inkscape_ (to render SVG files)
3331

@@ -44,7 +42,7 @@ Running the tests
4442

4543
Running the tests is simple. Make sure you have pytest installed and run::
4644

47-
py.test
45+
pytest
4846

4947
or::
5048

@@ -74,22 +72,22 @@ To run a single test from the command line, you can provide a file path,
7472
optionally followed by the function separated by two colons, e.g., (tests do
7573
not need to be installed, but Matplotlib should be)::
7674

77-
py.test lib/matplotlib/tests/test_simplification.py::test_clipping
75+
pytest lib/matplotlib/tests/test_simplification.py::test_clipping
7876

7977
or, if tests are installed, a dot-separated path to the module, optionally
8078
followed by the function separated by two colons, such as::
8179

82-
py.test --pyargs matplotlib.tests.test_simplification::test_clipping
80+
pytest --pyargs matplotlib.tests.test_simplification::test_clipping
8381

8482
If you want to run the full test suite, but want to save wall time try
8583
running the tests in parallel::
8684

87-
py.test --verbose -n 5
85+
pytest --verbose -n 5
8886

8987
Depending on your version of Python and pytest-xdist, you may need to set
9088
``PYTHONHASHSEED`` to a fixed value when running in parallel::
9189

92-
PYTHONHASHSEED=0 py.test --verbose -n 5
90+
PYTHONHASHSEED=0 pytest --verbose -n 5
9391

9492
An alternative implementation that does not look at command line arguments
9593
and works from within Python is to run the tests from the Matplotlib library

doc/sphinxext/mock_gui_toolkits.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import sys
2-
3-
try:
4-
from unittest.mock import MagicMock
5-
except ImportError:
6-
from mock import MagicMock
2+
from unittest.mock import MagicMock
73

84

95
class MyCairoCffi(MagicMock):

lib/matplotlib/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,12 +1478,8 @@ def _init_tests():
14781478

14791479
try:
14801480
import pytest
1481-
try:
1482-
from unittest import mock
1483-
except ImportError:
1484-
import mock
14851481
except ImportError:
1486-
print("matplotlib.test requires pytest and mock to run.")
1482+
print("matplotlib.test requires pytest to run.")
14871483
raise
14881484

14891485

lib/matplotlib/tests/test_backend_qt4.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
from __future__ import absolute_import, division, print_function
1+
import copy
2+
from unittest.mock import Mock
23

34
from matplotlib import pyplot as plt
45
from matplotlib._pylab_helpers import Gcf
56
import matplotlib
6-
import copy
77

88
import pytest
9-
try:
10-
# mock in python 3.3+
11-
from unittest import mock
12-
except ImportError:
13-
import mock
149

1510
with matplotlib.rc_context(rc={'backend': 'Qt4Agg'}):
1611
qt_compat = pytest.importorskip('matplotlib.backends.qt_compat')
@@ -91,7 +86,7 @@ def test_correct_key(qt_key, qt_mods, answer):
9186
"""
9287
qt_canvas = plt.figure().canvas
9388

94-
event = mock.Mock()
89+
event = Mock()
9590
event.isAutoRepeat.return_value = False
9691
event.key.return_value = qt_key
9792
event.modifiers.return_value = qt_mods

lib/matplotlib/tests/test_backend_qt5.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
from __future__ import absolute_import, division, print_function
2-
31
import copy
2+
from unittest import mock
43

54
import matplotlib
65
from matplotlib import pyplot as plt
76
from matplotlib._pylab_helpers import Gcf
87

98
import pytest
10-
try:
11-
# mock in python 3.3+
12-
from unittest import mock
13-
except ImportError:
14-
import mock
159

1610
with matplotlib.rc_context(rc={'backend': 'Qt5Agg'}):
1711
qt_compat = pytest.importorskip('matplotlib.backends.qt_compat',

lib/matplotlib/tests/test_dates.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
from __future__ import absolute_import, division, print_function
2-
3-
from six.moves import map
4-
5-
61
import datetime
7-
import dateutil
82
import tempfile
3+
from unittest.mock import Mock
94

5+
import dateutil
106
import numpy as np
117
import pytest
128
import pytz
139

14-
try:
15-
# mock in python 3.3+
16-
from unittest import mock
17-
except ImportError:
18-
import mock
19-
2010
from matplotlib.testing.decorators import image_comparison
2111
import matplotlib.pyplot as plt
2212
import matplotlib.dates as mdates
@@ -270,7 +260,7 @@ def test_strftime_fields(dt):
270260

271261
def test_date_formatter_callable():
272262
scale = -11
273-
locator = mock.Mock(_get_unit=mock.Mock(return_value=scale))
263+
locator = Mock(_get_unit=Mock(return_value=scale))
274264
callable_formatting_function = (lambda dates, _:
275265
[dt.strftime('%d-%m//%Y') for dt in dates])
276266

lib/matplotlib/tests/test_legend.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
from __future__ import absolute_import, division, print_function
2-
3-
try:
4-
# mock in python 3.3+
5-
from unittest import mock
6-
except ImportError:
7-
import mock
81
import collections
2+
import inspect
3+
from unittest import mock
4+
95
import numpy as np
106
import pytest
117

12-
138
from matplotlib.testing.decorators import image_comparison
149
import matplotlib.pyplot as plt
1510
import matplotlib as mpl
1611
import matplotlib.transforms as mtransforms
1712
import matplotlib.collections as mcollections
1813
from matplotlib.legend_handler import HandlerTuple
1914
import matplotlib.legend as mlegend
20-
import inspect
2115

2216

2317
# test that docstrigs are the same

lib/matplotlib/tests/test_rcparams.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1-
from __future__ import absolute_import, division, print_function
2-
31
import six
42

3+
from collections import OrderedDict
54
import os
5+
from unittest import mock
66
import warnings
7-
from collections import OrderedDict
87

98
from cycler import cycler, Cycler
109
import pytest
1110

12-
try:
13-
from unittest import mock
14-
except ImportError:
15-
import mock
1611
import matplotlib as mpl
1712
import matplotlib.pyplot as plt
1813
import matplotlib.colors as mcolors

lib/matplotlib/tests/test_units.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1+
import datetime
2+
from unittest.mock import MagicMock
3+
14
from matplotlib.cbook import iterable
25
import matplotlib.pyplot as plt
36
from matplotlib.testing.decorators import image_comparison
47
import matplotlib.units as munits
58
import numpy as np
6-
import datetime
7-
8-
try:
9-
# mock in python 3.3+
10-
from unittest.mock import MagicMock
11-
except ImportError:
12-
from mock import MagicMock
139

1410

1511
# Basic class that wraps numpy array and has units

lib/matplotlib/tests/test_widgets.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
from __future__ import absolute_import, division, print_function
2-
3-
try:
4-
# mock in python 3.3+
5-
from unittest import mock
6-
except ImportError:
7-
import mock
1+
from unittest.mock import Mock
82

93
import matplotlib.widgets as widgets
104
import matplotlib.pyplot as plt
@@ -60,7 +54,7 @@ def do_event(tool, etype, button=1, xdata=0, ydata=0, key=None, step=1):
6054
*step*
6155
number of scroll steps (positive for 'up', negative for 'down')
6256
"""
63-
event = mock.Mock()
57+
event = Mock()
6458
event.button = button
6559
ax = tool.ax
6660
event.x, event.y = ax.transData.transform([(xdata, ydata),

tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# $ python tests.py -v -d
66
#
7-
# The arguments are identical to the arguments accepted by py.test.
7+
# The arguments are identical to the arguments accepted by pytest.
88
#
99
# See http://doc.pytest.org/ for a detailed description of these options.
1010

0 commit comments

Comments
 (0)