8000 Merge pull request #7887 from QuLogic/pytest-mpl_toolkits · matplotlib/matplotlib@aabb6e8 · GitHub
[go: up one dir, main page]

Skip to content

Commit aabb6e8

Browse files
authored
Merge pull request #7887 from QuLogic/pytest-mpl_toolkits
MAINT: Convert mpl toolkits tests to pytest + minor cleanup
2 parents bb4d920 + af79d51 commit aabb6e8

File tree

4 files changed

+9
-72
lines changed

4 files changed

+9
-72
lines changed

lib/matplotlib/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,9 +1507,6 @@ def _jupyter_nbextension_paths():
15071507
'matplotlib.tests.test_cycles',
15081508
'matplotlib.tests.test_preprocess_data',
15091509
'matplotlib.sphinxext.tests.test_tinypages',
1510-
'mpl_toolkits.tests.test_mplot3d',
1511-
'mpl_toolkits.tests.test_axes_grid1',
1512-
'mpl_toolkits.tests.test_axes_grid',
15131510
]
15141511

15151512

lib/mpl_toolkits/tests/__init__.py

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
from __future__ import (absolute_import, division, print_function,
22
unicode_literals)
33

4-
import six
5-
6-
import difflib
74
import os
85

9-
from matplotlib import rcParams, rcdefaults, use
10-
116

127
_multiprocess_can_split_ = True
138

@@ -20,49 +15,3 @@
2015
'This is most likely because the test data is not installed. '
2116
'You may need to install matplotlib from source to get the '
2217
'test data.')
23-
24-
25-
def setup():
26-
# The baseline images are created in this locale, so we should use
27-
# it during all of the tests.
28-
import locale
29-
import warnings
30-
from matplotlib.backends import backend_agg, backend_pdf, backend_svg
31-
32-
try:
33-
locale.setlocale(locale.LC_ALL, str('en_US.UTF-8'))
34-
except locale.Error:
35-
try:
36-
locale.setlocale(locale.LC_ALL, str('English_United States.1252'))
37-
except locale.Error:
38-
warnings.warn(
39-
"Could not set locale to English/United States. "
40-
"Some date-related tests may fail")
41-
42-
use('Agg', warn=False) # use Agg backend for these tests
43-
44-
# These settings *must* be hardcoded for running the comparison
45-
# tests and are not necessarily the default values as specified in
46-
# rcsetup.py
47-
rcdefaults() # Start with all defaults
48-
rcParams['font.family'] = 'Bitstream Vera Sans'
49-
rcParams['text.hinting'] = False
50-
rcParams['text.hinting_factor'] = 8
51-
52-
53-
def assert_str_equal(reference_str, test_str,
54-
format_str=('String {str1} and {str2} do not '
55-
'match:\n{differences}')):
56-
"""
57-
Assert the two strings are equal. If not, fail and print their
58-
diffs using difflib.
59-
60-
"""
61-
if reference_str != test_str:
62-
diff = difflib.unified_diff(reference_str.splitlines(1),
63-
test_str.splitlines(1),
64-
'Reference', 'Test result',
65-
'', '', 0)
66-
raise ValueError(format_str.format(str1=reference_str,
67-
str2=test_str,
68-
differences=''.join(diff)))

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,3 @@ def get_demo_image():
155155
pad=0.1, borderpad=0.5, sep=5,
156156
frameon=False)
157157
ax.add_artist(asb)
158-
159-
160-
if __name__ == '__main__':
161-
import nose
162-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from nose.tools import assert_raises
1+
import pytest
2+
23
from mpl_toolkits.mplot3d import Axes3D, axes3d, proj3d
34
from matplotlib import cm
45
from matplotlib.testing.decorators import image_comparison, cleanup
@@ -222,7 +223,7 @@ def test_wireframe3dzerostrideraises():
222223
fig = plt.figure()
223224
ax = fig.add_subplot(111, projection='3d')
224225
X, Y, Z = axes3d.get_test_data(0.05)
225-
with assert_raises(ValueError):
226+
with pytest.raises(ValueError):
226227
ax.plot_wireframe(X, Y, Z, rstride=0, cstride=0)
227228

228229

@@ -231,9 +232,9 @@ def test_mixedsamplesraises():
231232
fig = plt.figure()
232233
ax = fig.add_subplot(111, projection='3d')
233234
X, Y, Z = axes3d.get_test_data(0.05)
234-
with assert_raises(ValueError):
235+
with pytest.raises(ValueError):
235236
ax.plot_wireframe(X, Y, Z, rstride=10, ccount=50)
236-
with assert_raises(ValueError):
237+
with pytest.raises(ValueError):
237238
ax.plot_surface(X, Y, Z, cstride=50, rcount=10)
238239

239240

@@ -316,16 +317,15 @@ def test_quiver3d_pivot_tail():
316317

317318
@image_comparison(baseline_images=['axes3d_labelpad'], extensions=['png'])
318319
def test_axes3d_labelpad():
319-
from nose.tools import assert_equal
320320
from matplotlib import rcParams
321321

322322
fig = plt.figure()
323323
ax = Axes3D(fig)
324324
# labelpad respects rcParams
325-
assert_equal(ax.xaxis.labelpad, rcParams['axes.labelpad'])
325+
assert ax.xaxis.labelpad == rcParams['axes.labelpad']
326326
# labelpad can be set in set_label
327327
ax.set_xlabel('X LABEL', labelpad=10)
328-
assert_equal(ax.xaxis.labelpad, 10)
328+
assert ax.xaxis.labelpad == 10
329329
ax.set_ylabel('Y LABEL')
330330
ax.set_zlabel('Z LABEL')
331331
# or manually
@@ -354,7 +354,8 @@ def test_plotsurface_1d_raises():
354354

355355
fig = plt.figure(figsize=(14,6))
356356
ax = fig.add_subplot(1, 2, 1, projection='3d')
357-
assert_raises(ValueError, ax.plot_surface, X, Y, z)
357+
with pytest.raises(ValueError):
358+
ax.plot_surface(X, Y, z)
358359

359360

360361
def _test_proj_make_M():
@@ -467,8 +468,3 @@ def test_lines_dists():
467468

468469
ax.set_xlim(-50, 150)
469470
ax.set_ylim(0, 300)
470-
471-
472-
if __name__ == '__main__':
473-
import nose
474-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)
0