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

Skip to content

Commit 1be56c8

Browse files
authored
Merge pull request #7884 from NelleV/pytest_c_models
MAINT moved "c" modules to pytest
2 parents 59478d2 + 9e84908 commit 1be56c8

7 files changed

Lines changed: 27 additions & 90 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,12 +1487,6 @@ def _jupyter_nbextension_paths():
14871487
'matplotlib.tests.test_basic',
14881488
'matplotlib.tests.test_bbox_tight',
14891489
'matplotlib.tests.test_coding_standards',
1490-
'matplotlib.tests.test_collections',
1491-
'matplotlib.tests.test_colorbar',
1492-
'matplotlib.tests.test_colors',
1493-
'matplotlib.tests.test_compare_images',
1494-
'matplotlib.tests.test_container',
1495-
'matplotlib.tests.test_contour',
14961490
'matplotlib.tests.test_dates',
14971491
'matplotlib.tests.test_dviread',
14981492
'matplotlib.tests.test_figure',

lib/matplotlib/tests/test_collections.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
from __future__ import (absolute_import, division, print_function,
55
unicode_literals)
66

7-
import six
8-
97
import io
108

11-
from nose.tools import assert_equal
129
import numpy as np
1310
from numpy.testing import assert_array_equal, assert_array_almost_equal
14-
from nose.plugins.skip import SkipTest
11+
from numpy.testing import assert_equal
12+
import pytest
1513

1614
import matplotlib.pyplot as plt
1715
import matplotlib.collections as mcollections
@@ -436,7 +434,7 @@ def test_add_collection():
436434
def test_quiver_limits():
437435
ax = plt.axes()
438436
x, y = np.arange(8), np.arange(10)
439-
data = u = v = np.linspace(0, 10, 80).reshape(10, 8)
437+
u = v = np.linspace(0, 10, 80).reshape(10, 8)
440438
q = plt.quiver(x, y, u, v)
441439
assert_equal(q.get_datalim(ax.transData).bounds, (0., 0., 7., 9.))
442440

@@ -620,10 +618,7 @@ def test_size_in_xy():
620618

621619
@cleanup
622620
def test_pandas_indexing():
623-
try:
624-
import pandas as pd
625-
except ImportError:
626-
raise SkipTest("Pandas not installed")
621+
pd = pytest.importorskip('pandas')
627622

628623
# Should not fail break when faced with a
629624
# non-zero indexed series
@@ -652,8 +647,3 @@ def test_lslw_bcast():
652647
col.set_linestyles(['-', '-', '-'])
653648
assert col.get_linestyles() == [(None, None)] * 3
654649
assert col.get_linewidths() == [1, 2, 3]
655-
656-
657-
if __name__ == '__main__':
658-
import nose
659-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_colorbar.py

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

4-
import six
5-
64
import numpy as np
7-
from numpy import ma
8-
import matplotlib
95
from matplotlib import rc_context
106
from matplotlib.testing.decorators import image_comparison, cleanup
117
import matplotlib.pyplot as plt
12-
from matplotlib import rcParams
138
from matplotlib.colors import BoundaryNorm, LogNorm
149
from matplotlib.cm import get_cmap
15-
from matplotlib import cm
1610
from matplotlib.colorbar import ColorbarBase
1711

1812

@@ -91,10 +85,10 @@ def _colorbar_extension_length(spacing):
9185
cax.get_xticklines() + cax.get_yticklines():
9286
item.set_visible(False)
9387
# Generate the colorbar.
94-
cb = ColorbarBase(cax, cmap=cmap, norm=norm,
95-
boundaries=boundaries, values=values,
96-
extend=extension_type, extendfrac=extendfrac,
97-
orientation='horizontal', spacing=spacing)
88+
ColorbarBase(cax, cmap=cmap, norm=norm,
89+
boundaries=boundaries, values=values,
90+
extend=extension_type, extendfrac=extendfrac,
91+
orientation='horizontal', spacing=spacing)
9892
# Return the figure to the caller.
9993
return fig
10094

@@ -106,8 +100,8 @@ def _colorbar_extension_length(spacing):
106100
def test_colorbar_extension_shape():
107101
'''Test rectangular colorbar extensions.'''
108102
# Create figures for uniform and proportionally spaced colorbars.
109-
fig1 = _colorbar_extension_shape('uniform')
110-
fig2 = _colorbar_extension_shape('proportional')
103+
_colorbar_extension_shape('uniform')
104+
_colorbar_extension_shape('proportional')
111105

112106

113107
@image_comparison(baseline_images=['colorbar_extensions_uniform',
@@ -116,8 +110,8 @@ def test_colorbar_extension_shape():
116110
def test_colorbar_extension_length():
117111
'''Test variable length colorbar extensions.'''
118112
# Create figures for uniform and proportionally spaced colorbars.
119-
fig1 = _colorbar_extension_length('uniform')
120-
fig2 = _colorbar_extension_length('proportional')
113+
_colorbar_extension_length('uniform')
114+
_colorbar_extension_length('proportional')
121115

122116

123117
@image_comparison(baseline_images=['cbar_with_orientation',
@@ -332,8 +326,3 @@ def test_colorbar_lognorm_extension():
332326
cb = ColorbarBase(ax, norm=LogNorm(vmin=0.1, vmax=1000.0),
333327
orientation='vertical', extend='both')
334328
assert cb._values[0] >= 0.0
335-
336-
337-
if __name__ == '__main__':
338-
import nose
339-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_colors.py

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,13 @@
33

44
import six
55
import itertools
6+
import pytest
67
from distutils.version import LooseVersion as V
78

8-
from nose.tools import assert_raises, assert_equal, assert_true
9-
from nose.tools import assert_sequence_equal
10-
11-
try:
12-
# this is not available in nose + py2.6
13-
from nose.tools import assert_sequence_equal
14-
except ImportError:
15-
assert_sequence_equal = None
16-
179
import numpy as np
10+
11+
from numpy.testing import assert_raises, assert_equal
1812
from numpy.testing.utils import assert_array_equal, assert_array_almost_equal
19-
from nose.plugins.skip import SkipTest
2013

2114
from matplotlib import cycler
2215
import matplotlib
@@ -103,7 +96,7 @@ def test_BoundaryNorm():
10396
expected = [-1, 0, 1, 2]
10497
for v, ex in zip(vals, expected):
10598
ret = bn(v)
106-
assert_true(isinstance(ret, six.integer_types))
99+
assert isinstance(ret, six.integer_types)
107100
assert_array_equal(ret, ex)
108101
assert_array_equal(bn([v]), ex)
109102

@@ -112,7 +105,7 @@ def test_BoundaryNorm():
112105
expected = [-1, 0, 2, 3]
113106
for v, ex in zip(vals, expected):
114107
ret = bn(v)
115-
assert_true(isinstance(ret, six.integer_types))
108+
assert isinstance(ret, six.integer_types)
116109
assert_array_equal(ret, ex)
117110
assert_array_equal(bn([v]), ex)
118111

@@ -121,7 +114,7 @@ def test_BoundaryNorm():
121114
expected = [0, 0, 2, 2]
122115
for v, ex in zip(vals, expected):
123116
ret = bn(v)
124-
assert_true(isinstance(ret, six.integer_types))
117+
assert isinstance(ret, six.integer_types)
125118
assert_array_equal(ret, ex)
126119
assert_array_equal(bn([v]), ex)
127120

@@ -142,9 +135,9 @@ def test_BoundaryNorm():
142135

143136
# Non-trivial masked arrays
144137
vals = np.ma.masked_invalid([np.Inf, np.NaN])
145-
assert_true(np.all(bn(vals).mask))
138+
assert np.all(bn(vals).mask)
146139
vals = np.ma.masked_invalid([np.Inf])
147-
assert_true(np.all(bn(vals).mask))
140+
assert np.all(bn(vals).mask)
148141

149142

150143
def test_LogNorm():
@@ -606,20 +599,15 @@ def _azimuth2math(azimuth, elevation):
606599

607600

608601
def test_pandas_iterable():
609-
try:
610-
import pandas as pd
611-
except ImportError:
612-
raise SkipTest("Pandas not installed")
613-
if assert_sequence_equal is None:
614-
raise SkipTest("nose lacks required function")
602+
pd = pytest.importorskip('pandas')
615603
# Using a list or series yields equivalent
616604
# color maps, i.e the series isn't seen as
617605
# a single color
618606
lst = ['red', 'blue', 'green']
619607
s = pd.Series(lst)
620608
cm1 = mcolors.ListedColormap(lst, N=5)
621609
cm2 = mcolors.ListedColormap(s, N=5)
622-
assert_sequence_equal(cm1.colors, cm2.colors)
610+
assert_array_equal(cm1.colors, cm2.colors)
623611

624612

625613
def test_colormap_reversing():
@@ -684,8 +672,3 @@ def test_tableau_order():
684672
'#bcbd22', '#17becf']
685673

686674
assert list(mcolors.TABLEAU_COLORS.values()) == dflt_cycle
687-
688-
689-
if __name__ == '__main__':
690-
import nose
691-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_compare_images.py

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

4-
import six
5-
64
import os
75
import shutil
86

9-
from nose.tools import assert_equal, assert_not_equal, assert_almost_equal
7+
from numpy.testing import assert_equal, assert_almost_equal
108

119
from matplotlib.testing.compare import compare_images
1210
from matplotlib.testing.decorators import _image_directories
@@ -39,8 +37,8 @@ def image_comparison_expect_rms(im1, im2, tol, expect_rms):
3937
if expect_rms is None:
4038
assert_equal(None, results)
4139
else:
42-
assert_not_equal(None, results)
43-
assert_almost_equal(expect_rms, results['rms'], places=4)
40+
assert results is not None
41+
assert_almost_equal(expect_rms, results['rms'], decimal=4)
4442

4543

4644
def test_image_compare_basic():
@@ -99,8 +97,3 @@ def test_image_compare_shade_difference():
9997

10098
# Now test the reverse comparison.
10199
image_comparison_expect_rms(im2, im1, tol=0, expect_rms=1.0)
102-
103-
104-
if __name__ == '__main__':
105-
import nose
106-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_contour.py

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

4-
import six
5-
64
import datetime
75

86
import numpy as np
97
from matplotlib import mlab
108
from matplotlib.testing.decorators import cleanup, image_comparison
119
from matplotlib import pyplot as plt
12-
from nose.tools import assert_equal, assert_raises
10+
from numpy.testing import assert_equal, assert_raises
1311
from numpy.testing import assert_array_almost_equal
1412
import warnings
1513

@@ -321,8 +319,3 @@ def test_contourf_symmetric_locator():
321319
locator = plt.MaxNLocator(nbins=4, symmetric=True)
322320
cs = plt.contourf(z, locator=locator)
323321
assert_array_almost_equal(cs.levels, np.linspace(-12, 12, 5))
324-
325-
326-
if __name__ == '__main__':
327-
import nose
328-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_cycles.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from matplotlib.cbook import MatplotlibDeprecationWarning
55
import matplotlib.pyplot as plt
66
import numpy as np
7-
from nose.tools import assert_raises
7+
from numpy.testing import assert_raises
88

99
from cycler import cycler
1010

@@ -213,8 +213,3 @@ def test_invalid_input_forms():
213213
cycler(foobar=[1, 2]))
214214
assert_raises(ValueError, ax.set_prop_cycle,
215215
cycler(color='rgb', c='cmy'))
216-
217-
218-
if __name__ == '__main__':
219-
import nose
220-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

0 commit comments

Comments
 (0)