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

Skip to content

Commit 0e17dfe

Browse files
committed
MAINT moved test_colors to pytest
1 parent 2dcc395 commit 0e17dfe

1 file changed

Lines changed: 10 additions & 27 deletions

File tree

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)

0 commit comments

Comments
 (0)