8000 added integration tests · QuLogic/matplotlib@e92682d · GitHub
[go: up one dir, main page]

Skip to content

Commit e92682d

Browse files
committed
added integration tests
1 parent cf95c21 commit e92682d

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

lib/matplotlib/tests/test_preprocess_data.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import pytest
55

66
from matplotlib import _preprocess_data
7-
7+
from matplotlib.axes import Axes
8+
from matplotlib.testing.decorators import check_figures_equal
89

910
# Notes on testing the plotting functions itself
1011
# * the individual decorated plotting functions are tested in 'test_axes.py'
@@ -72,11 +73,18 @@ def test_function_call_without_data(func):
7273
assert (func(None, x="x", y="y", label="text") ==
7374
"x: ['x'], y: ['y'], ls: x, w: xyz, label: text")
7475

76+
@pytest.mark.parametrize('func', all_funcs, ids=all_func_ids)
77+
def test_function_call_with_dict_input(func):
78+
"""Tests with dict input, unpacking via preprocess_pipeline"""
79+
data = {'a': 1, 'b': 2}
80+
assert(func(None, data.keys(), data.values()) ==
81+
"x: ['a', 'b'], y: [1, 2], ls: x, w: xyz, label: None")
82+
7583

7684
@pytest.mark.parametrize('func', all_funcs, ids=all_func_ids)
7785
def test_function_call_with_dict_data(func):
7886
"""Test with dict data -> label comes from the value of 'x' parameter."""
79-
data = {"a": [1, 2], "b": [8, 9], "w": "NOT"}
87+
data = {'a': [1, 2], 'b': [8, 9], "w": "NOT"}
8088
assert (func(None, "a", "b", data=data) ==
8189
"x: [1, 2], y: [8, 9], ls: x, w: xyz, label: b")
8290
assert (func(None, x="a", y="b", data=data) ==
@@ -215,3 +223,29 @@ def funcy(ax, x, y, z, t=None):
215223
assert not re.search(r"every other argument", funcy.__doc__)
216224
assert not re.search(r"the following arguments .*: \*x\*, \*t\*\.",
217225
funcy.__doc__)
226+
227+
228+
class TestPlotTypes:
229+
plotters = [Axes.scatter, Axes.bar, Axes.plot]
230+
231+
@pytest.mark.parametrize('plotter', plotters)
232+
@check_figures_equal(extensions=['png'])
233+
def test_dict_unpack(self, plotter, fig_test, fig_ref):
234+
x = [1,2,3]
235+
y = [4,5,6]
236+
ddict = dict(zip(x,y))
237+
238+
plotter(fig_test.subplots(),
239+
ddict.keys(), ddict.values())
240+
plotter(fig_ref.subplots(), x, y)
241+
242+
@pytest.mark.parametrize('plotter', plotters)
243+
@check_figures_equal(extensions=['png'])
244+
def test_data_kwarg(self, plotter, fig_test, fig_ref):
245+
x = [1,2,3]
246+
y = [4,5,6]
247+
248+
plotter(fig_test.subplots(), 'xval', 'yval',
249+
data={'xval':x, 'yval':y})
250+
plotter(fig_ref.subplots(), x, y)
251+

0 commit comments

Comments
 (0)
0