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

Skip to content

Commit a77bb03

Browse files
committed
TST: refactor empty-data test to use check_figures_equal
1 parent 2a57338 commit a77bb03

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -779,21 +779,21 @@ def test_nonfinite_limits():
779779
ax.plot(x, y)
780780

781781

782-
@pytest.mark.parametrize('plot_fun, lims',
783-
[[plt.plot, (14610.0, 14974.0)],
784-
[plt.scatter, (14591.8, 14992.2)]])
785-
def test_limits_empty_data(plot_fun, lims):
782+
@pytest.mark.style('default')
783+
@pytest.mark.parametrize('plot_fun',
784+
['scatter', 'plot', 'fill_between'])
785+
@check_figures_equal(extensions=["png"])
786+
def test_limits_empty_data(plot_fun, fig_test, fig_ref):
786787
# Check that plotting empty data doesn't change autoscaling of dates
787788
x = np.arange("2010-01-01", "2011-01-01", dtype="datetime64[D]")
788789

789-
fig, ax = plt.subplots()
790-
plot_fun(x, np.arange(len(x)))
791-
assert ax.get_xlim() == lims
790+
ax_test = fig_test.subplots()
791+
ax_ref = fig_ref.subplots()
792792

793-
fig, ax = plt.subplots()
794-
plot_fun([], [])
795-
plot_fun(x, np.arange(len(x)))
796-
assert ax.get_xlim() == lims
793+
getattr(ax_test, plot_fun)([], [])
794+
795+
for ax in [ax_test, ax_ref]:
796+
getattr(ax, plot_fun)(x, range(len(x)), color='C0')
797797

798798

799799
@image_comparison(['imshow', 'imshow'], remove_text=True, style='mpl20')

0 commit comments

Comments
 (0)