8000 MAINT moved g-i-l* modules to pytest by NelleV · Pull Request #7898 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

MAINT moved g-i-l* modules to pytest #7898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,10 +1497,6 @@ def _jupyter_nbextension_paths():
'matplotlib.tests.test_dviread',
'matplotlib.tests.test_figure',
'matplotlib.tests.test_font_manager',
'matplotlib.tests.test_gridspec',
'matplotlib.tests.test_image',
'matplotlib.tests.test_legend',
'matplotlib.tests.test_lines',
'matplotlib.tests.test_mathtext',
'matplotlib.tests.test_mlab',
'matplotlib.tests.test_offsetbox',
Expand Down
11 changes: 6 additions & 5 deletions lib/matplotlib/tests/test_gridspec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import matplotlib.gridspec as gridspec
from nose.tools import assert_raises, assert_equal
from numpy.testing import assert_equal
import pytest


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


def test_height_ratios():
"""
Addresses issue #5835.
See at https://github.com/matplotlib/matplotlib/issues/5835.
"""
assert_raises(ValueError, gridspec.GridSpec,
1, 1, height_ratios=[2, 1, 3])
with pytest.raises(ValueError):
gridspec.GridSpec(1, 1, height_ratios=[2, 1, 3])
17 changes: 4 additions & 13 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import os
import warnings

from nose.plugins.attrib import attr

import numpy as np
from numpy.testing import assert_array_equal

from matplotlib.testing.decorators import (image_comparison,
knownfailureif, cleanup)
Expand All @@ -20,17 +20,12 @@
import matplotlib.pyplot as plt

from matplotlib import mlab
from nose.tools import assert_raises
from numpy.testing import (
assert_array_equal, assert_array_almost_equal, assert_allclose)
import pytest

from copy import copy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert_array_equal is used in a few of the tests.

from numpy import ma
import matplotlib.colors as colors
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import numpy as np

import nose

try:
from PIL import Image
Expand Down Expand Up @@ -592,7 +587,7 @@ def test_minimized_rasterized():
assert False


@attr('network')
@pytest.mark.network
def test_load_from_url():
req = six.moves.urllib.request.urlopen(
"http://matplotlib.org/_static/logo_sidebar_horiz.png")
Expand Down Expand Up @@ -753,7 +748,3 @@ def test_imshow_no_warn_invalid():
warnings.simplefilter("always")
plt.imshow([[1, 2], [3, np.nan]])
assert len(warns) == 0


if __name__ == '__main__':
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
20 changes: 9 additions & 11 deletions lib/matplotlib/tests/test_legend.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
from six.moves import xrange
try:
# mock in python 3.3+
from unittest import mock
except ImportError:
import mock
from nose.tools import assert_equal
from numpy.testing import assert_equal
import numpy as np

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


Expand Down Expand Up @@ -123,9 +121,9 @@ def test_alpha_rcparam():
def test_fancy():
# using subplot triggers some offsetbox functionality untested elsewhere
plt.subplot(121)
plt.scatter(list(xrange(10)), list(xrange(10, 0, -1)), label='XX\nXX')
plt.scatter(np.arange(10), np.arange(10, 0, -1), label='XX\nXX')
plt.plot([5] * 10, 'o--', label='XX')
plt.errorbar(list(xrange(10)), list(xrange(10)), xerr=0.5,
plt.errorbar(np.arange(10), np.arange(10), xerr=0.5,
yerr=0.5, label='XX')
plt.legend(loc="center left", bbox_to_anchor=[1.0, 0.5],
ncol=2, shadow=True, title="My legend", numpoints=1)
Expand All @@ -143,16 +141,16 @@ def test_framealpha():
remove_text=True)
def test_rc():
# using subplot triggers some offsetbox functionality untested elsewhere
fig = plt.figure()
plt.figure()
ax = plt.subplot(121)
ax.scatter(list(xrange(10)), list(xrange(10, 0, -1)), label='three')
ax.scatter(np.arange(10), np.arange(10, 0, -1), label='three')
ax.legend(loc="center left", bbox_to_anchor=[1.0, 0.5],
title="My legend")

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

Expand Down
16 changes: 5 additions & 11 deletions lib/matplotlib/tests/test_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
import itertools
import matplotlib.lines as mlines
import nose
from nose.tools import assert_true, assert_raises
from numpy.testing import assert_raises
from timeit import repeat
import numpy as np
from cycler import cycler
Expand Down Expand Up @@ -59,7 +57,7 @@ def test_invisible_Line_rendering():

slowdown_factor = (t_unvisible_line/t_no_line)
slowdown_threshold = 2 # trying to avoid false positive failures
assert_true(slowdown_factor < slowdown_threshold)
assert slowdown_factor < slowdown_threshold


@cleanup
Expand Down Expand Up @@ -186,10 +184,6 @@ def test_lw_scaling():

def test_nan_is_sorted():
line = mlines.Line2D([], [])
assert_true(line._is_sorted(np.array([1, 2, 3])))
assert_true(line._is_sorted(np.array([1, np.nan, 3])))
assert_true(not line._is_sorted([3, 5] + [np.nan] * 100 + [0, 2]))


if __name__ == '__main__':
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
assert line._is_sorted(np.array([1, 2, 3]))
assert line._is_sorted(np.array([1, np.nan, 3]))
assert not line._is_sorted([3, 5] + [np.nan] * 100 + [0, 2])
0