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

Skip to content

Commit 0fe9994

Browse files
use figure-equality tests for zero-width dashed rendering
1 parent 3f42ea8 commit 0fe9994

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

lib/matplotlib/tests/test_axes.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8081,17 +8081,19 @@ def test_twinning_default_axes_class():
80818081
assert type(twiny) is Axes
80828082

80838083

8084-
def test_zero_linewidth():
8085-
# Check that setting a zero linewidth doesn't error
8086-
plt.plot([0, 1], [0, 1], ls='--', lw=0)
8087-
plt.gcf().canvas.draw()
8084+
@check_figures_equal()
8085+
def test_zero_linewidth(fig_test, fig_ref):
8086+
fig_test.subplots().plot([0, 1], [0, 1], ls='--', lw=0)
8087+
fig_ref.subplots().plot([0, 1], [0, 1], ls='-', lw=0)
80888088

80898089

80908090
@mpl.style.context('mpl20')
8091-
def test_stairs_fill_zero_linewidth():
8092-
fig, ax = plt.subplots()
8093-
ax.stairs([1, 2, 3, 4], [1, 2, 3, 4, 5], fill=True, ls='--')
8094-
fig.canvas.draw()
8091+
@check_figures_equal()
8092+
def test_stairs_fill_zero_linewidth(fig_test, fig_ref):
8093+
fig_test.subplots().stairs(
8094+
[1, 2, 3, 4], [1, 2, 3, 4, 5], fill=True, ls='--')
8095+
fig_ref.subplots().stairs(
8096+
[1, 2, 3, 4], [1, 2, 3, 4, 5], fill=True, ls='-')
80958097

80968098

80978099
def test_empty_errorbar_legend():

lib/matplotlib/tests/test_patches.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,10 +907,12 @@ def test_default_linestyle():
907907
assert patch.get_linestyle() == 'solid'
908908

909909

910-
def test_patch_zero_linewidth_dashed_draw():
911-
fig, ax = plt.subplots()
912-
ax.add_patch(Rectangle((0, 0), 1, 1, fill=False, linewidth=0, linestyle='--'))
913-
fig.canvas.draw()
910+
@check_figures_equal()
911+
def test_patch_zero_linewidth_dashed_draw(fig_test, fig_ref):
912+
fig_test.subplots().add_patch(
913+
Rectangle((0, 0), 1, 1, fill=False, linewidth=0, linestyle='--'))
914+
fig_ref.subplots().add_patch(
915+
Rectangle((0, 0), 1, 1, fill=False, linewidth=0, linestyle='-'))
914916

915917

916918
def test_default_capstyle():

0 commit comments

Comments
 (0)