From f76a010ba2c13d719669ccf5d652ff24d4f26fe3 Mon Sep 17 00:00:00 2001 From: patniharshit Date: Wed, 7 Jun 2017 20:12:13 +0530 Subject: [PATCH 1/2] Parameterize test_fill_between and test_fill_betweenx --- lib/matplotlib/tests/test_axes.py | 78 +++++++------------------------ 1 file changed, 17 insertions(+), 61 deletions(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 86b6f2a3ddc2..5eb9faf48b31 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -847,40 +847,32 @@ def test_polycollection_joinstyle(): ax.set_ybound(0, 3) -def test_fill_between_2d_x_input(): - x = np.zeros((2, 2)) - y1 = 3 - y2 = 3 - - fig = plt.figure() - ax = fig.add_subplot(211) - with pytest.raises(ValueError): - ax.plot(x, y1, x, y2, color='black') - ax.fill_between(x, y1, y2) - - -def test_fill_between_2d_y1_input(): - x = np.arange(0.0, 2, 0.02) - y1 = np.zeros((2, 2)) - y2 = 3 - +@pytest.mark.parametrize( + 'x, y1, y2', [ + (np.zeros((2, 2)), 3, 3), + (np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3), + (np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2))) + ] +) +def test_fill_between_input(x, y1, y2): fig = plt.figure() ax = fig.add_subplot(211) with pytest.raises(ValueError): - ax.plot(x, y1, x, y2, color='black') ax.fill_between(x, y1, y2) -def test_fill_between_2d_y2_input(): - x = np.arange(0.0, 2, 0.02) - y1 = 3 - y2 = np.zeros((2, 2)) - +@pytest.mark.parametrize( + 'y, x1, x2', [ + (np.zeros((2, 2)), 3, 3), + (np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3), + (np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2))) + ] +) +def test_fill_betweenx_input(y, x1, x2): fig = plt.figure() ax = fig.add_subplot(211) with pytest.raises(ValueError): - ax.plot(x, y1, x, y2, color='black') - ax.fill_between(x, y1, y2) + ax.fill_betweenx(y, x1, x2) @image_comparison(baseline_images=['fill_between_interpolate'], @@ -4995,42 +4987,6 @@ def test_tick_param_label_rotation(): assert text.get_rotation() == 90 -def test_fill_betweenx_2d_y_input(): - y = np.zeros((2, 2)) - x1 = 3 - x2 = 3 - - fig = plt.figure() - ax = fig.add_subplot(211) - with pytest.raises(ValueError): - ax.plot(y, x1, y, x2, color='black') - ax.fill_betweenx(y, x1, x2) - - -def test_fill_betweenx_2d_x1_input(): - y = np.arange(0.0, 2, 0.02) - x1 = np.zeros((2, 2)) - x2 = 3 - - fig = plt.figure() - ax = fig.add_subplot(211) - with pytest.raises(ValueError): - ax.plot(y, x1, y, x2, color='black') - ax.fill_betweenx(y, x1, x2) - - -def test_fill_betweenx_2d_x2_input(): - y = np.arange(0.0, 2, 0.02) - x1 = 3 - x2 = np.zeros((2, 2)) - - fig = plt.figure() - ax = fig.add_subplot(211) - with pytest.raises(ValueError): - ax.plot(y, x1, y, x2, color='black') - ax.fill_betweenx(y, x1, x2) - - @pytest.mark.style('default') def test_fillbetween_cycle(): fig, ax = plt.subplots() From a0ccb78c269311b4dd4d3b70ee87d989dd2ba1cb Mon Sep 17 00:00:00 2001 From: patniharshit Date: Thu, 8 Jun 2017 03:02:13 +0530 Subject: [PATCH 2/2] Add ids to test_fill_between tests --- lib/matplotlib/tests/test_axes.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 5eb9faf48b31..f1cc67fde7a4 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -852,6 +852,10 @@ def test_polycollection_joinstyle(): (np.zeros((2, 2)), 3, 3), (np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3), (np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2))) + ], ids=[ + '2d_x_input', + '2d_y1_input', + '2d_y2_input' ] ) def test_fill_between_input(x, y1, y2): @@ -866,6 +870,10 @@ def test_fill_between_input(x, y1, y2): (np.zeros((2, 2)), 3, 3), (np.arange(0.0, 2, 0.02), np.zeros((2, 2)), 3), (np.arange(0.0, 2, 0.02), 3, np.zeros((2, 2))) + ], ids=[ + '2d_y_input', + '2d_x1_input', + '2d_x2_input' ] ) def test_fill_betweenx_input(y, x1, x2):