8000 Merge pull request #7898 from NelleV/pytest_gil_modules · matplotlib/matplotlib@7f476f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7f476f5

Browse files
authored
Merge pull request #7898 from NelleV/pytest_gil_modules
MAINT moved g-i-l* modules to pytest
2 parents 6bbf92c + 32c3317 commit 7f476f5

File tree

5 files changed

+24
-44
lines changed

5 files changed

+24
-44
lines changed

lib/matplotlib/__init__.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,10 +1477,6 @@ def _jupyter_nbextension_paths():
14771477
'matplotlib.tests.test_coding_standards',
14781478
'matplotlib.tests.test_dviread',
14791479
'matplotlib.tests.test_font_manager',
1480-
'matplotlib.tests.test_gridspec',
1481-
'matplotlib.tests.test_image',
1482-
'matplotlib.tests.test_legend',
1483-
'matplotlib.tests.test_lines',
14841480
'matplotlib.tests.test_mathtext',
14851481
'matplotlib.tests.test_offsetbox',
14861482
'matplotlib.tests.test_patches',

lib/matplotlib/tests/test_gridspec.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import matplotlib.gridspec as gridspec
2-
from nose.tools import assert_raises, assert_equal
2+
from numpy.testing import assert_equal
3+
import pytest
34

45

56
def test_equal():
@@ -13,14 +14,14 @@ def test_width_ratios():
1314
Addresses issue #5835.
1415
See at https://github.com/matplotlib/matplotlib/issues/5835.
1516
"""
16-
assert_raises(ValueError, gridspec.GridSpec,
17-
1, 1, width_ratios=[2, 1, 3])
17+
with pytest.raises(ValueError):
18+
gridspec.GridSpec(1, 1, width_ratios=[2, 1, 3])
1819

1920

2021
def test_height_ratios():
2122
"""
2223
Addresses issue #5835.
2324
See at https://github.com/matplotlib/matplotlib/issues/5835.
2425
"""
25-
assert_raises(ValueError, gridspec.GridSpec,
26-
1, 1, height_ratios=[2, 1, 3])
26+
with pytest.raises(ValueError):
27+
gridspec.GridSpec(1, 1, height_ratios=[2, 1, 3])

lib/matplotlib/tests/test_image.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import os
77
import warnings
88

9-
from nose.plugins.attrib import attr
109

1110
import numpy as np
11+
from numpy.testing import assert_array_equal
1212

1313
from matplotlib.testing.decorators import (image_comparison,
1414
knownfailureif, cleanup)
@@ -20,17 +20,12 @@
2020
import matplotlib.pyplot as plt
2121

2222
from matplotlib import mlab
23-
from nose.tools import assert_raises
24-
from numpy.testing import (
25-
assert_array_equal, assert_array_almost_equal, assert_allclose)
23+
import pytest
24+
2625
from copy import copy
2726
from numpy import ma
2827
import matplotlib.colors as colors
29-
import matplotlib.pyplot as plt
30-
import matplotlib.mlab as mlab
31-
import numpy as np
3228

33-
import nose
3429

3530
try:
3631
from PIL import Image
@@ -592,7 +587,7 @@ def test_minimized_rasterized():
592587
assert False
593588

594589

595-
@attr('network')
590+
@pytest.mark.network
596591
def test_load_from_url():
597592
req = six.moves.urllib.request.urlopen(
598593
"http://matplotlib.org/_static/logo_sidebar_horiz.png")
@@ -753,7 +748,3 @@ def test_imshow_no_warn_invalid():
753748
warnings.simplefilter("always")
754749
plt.imshow([[1, 2], [3, np.nan]])
755750
assert len(warns) == 0
756-
757-
758-
if __name__ == '__main__':
759-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)

lib/matplotlib/tests/test_legend.py

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

4-
import six
5-
from six.moves import xrange
64
try:
75
# mock in python 3.3+
86
from unittest import mock
97
except ImportError:
108
import mock
11-
from nose.tools import assert_equal
9+
from numpy.testing import assert_equal
1210
import numpy as np
1311

1412
from matplotlib.testing.decorators import image_comparison, cleanup
@@ -59,9 +57,9 @@ def test_various_labels():
5957
# tests all sorts of label types
6058
fig = plt.figure()
6159
ax = fig.add_subplot(121)
62-
ax.plot(list(xrange(4)), 'o', label=1)
60+
ax.plot(np.arange(4), 'o', label=1)
6361
ax.plot(np.linspace(4, 4.1), 'o', label='D\xe9velopp\xe9s')
64-
ax.plot(list(xrange(4, 1, -1)), 'o', label='__nolegend__')
62+
ax.plot(np.arange(4, 1, -1), 'o', label='__nolegend__')
6563
ax.legend(numpoints=1, loc=0)
6664

6765

@@ -123,9 +121,9 @@ def test_alpha_rcparam():
123121
def test_fancy():
124122
# using subplot triggers some offsetbox functionality untested elsewhere
125123
plt.subplot(121)
126-
plt.scatter(list(xrange(10)), list(xrange(10, 0, -1)), label='XX\nXX')
124+
plt.scatter(np.arange(10), np.arange(10, 0, -1), label='XX\nXX')
127125
plt.plot([5] * 10, 'o--', label='XX')
128-
plt.errorbar(list(xrange(10)), list(xrange(10)), xerr=0.5,
126+
plt.errorbar(np.arange(10), np.arange(10), xerr=0.5,
129127
yerr=0.5, label='XX')
130128
plt.legend(loc="center left", bbox_to_anchor=[1.0, 0.5],
131129
ncol=2, shadow=True, title="My legend", numpoints=1)
@@ -143,16 +141,16 @@ def test_framealpha():
143141
remove_text=True)
144142
def test_rc():
145143
# using subplot triggers some offsetbox functionality untested elsewhere
146-
fig = plt.figure()
144+
plt.figure()
147145
ax = plt.subplot(121)
148-
ax.scatter(list(xrange(10)), list(xrange(10, 0, -1)), label='three')
146+
ax.scatter(np.arange(10), np.arange(10, 0, -1), label='three')
149147
ax.legend(loc="center left", bbox_to_anchor=[1.0, 0.5],
150148
title="My legend")
151149

152150
mpl.rcParams['legend.scatterpoints'] = 1
153-
fig = plt.figure()
151+
plt.figure()
154152
ax = plt.subplot(121)
155-
ax.scatter(list(xrange(10)), list(xrange(10, 0, -1)), label='one')
153+
ax.scatter(np.arange(10), np.arange(10, 0, -1), label='one')
156154
ax.legend(loc="center left", bbox_to_anchor=[1.0, 0.5],
157155
title="My legend")
158156

lib/matplotlib/tests/test_lines.py

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

7-
import six
87
import itertools
98
import matplotlib.lines as mlines
10-
import nose
11-
from nose.tools import assert_true, assert_raises
9+
from numpy.testing import assert_raises
1210
from timeit import repeat
1311
import numpy as np
1412
from cycler import cycler
@@ -59,7 +57,7 @@ def test_invisible_Line_rendering():
5957

6058
slowdown_factor = (t_unvisible_line/t_no_line)
6159
slowdown_threshold = 2 # trying to avoid false positive failures
62-
assert_true(slowdown_factor < slowdown_threshold)
60+
assert slowdown_factor < slowdown_threshold
6361

6462

6563
@cleanup
@@ -186,10 +184,6 @@ def test_lw_scaling():
186184

187185
def test_nan_is_sorted():
188186
line = mlines.Line2D([], [])
189-
assert_true(line._is_sorted(np.array([1, 2, 3])))
190-
assert_true(line._is_sorted(np.array([1, np.nan, 3])))
191-
assert_true(not line._is_sorted([3, 5] + [np.nan] * 100 + [0, 2]))
192-
193-
194-
if __name__ == '__main__':
195-
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
187+
assert line._is_sorted(np.array([1, 2, 3]))
188+
assert line._is_sorted(np.array([1, np.nan, 3]))
189+
assert not line._is_sorted([3, 5] + [np.nan] * 100 + [0, 2])

0 commit comments

Comments
 (0)
0