Skip to content

Commit aafeacd

Browse files
simplify zero-width dash regression tests
1 parent 7b3f389 commit aafeacd

2 files changed

Lines changed: 6 additions & 24 deletions

File tree

lib/matplotlib/tests/test_lines.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import itertools
66
import platform
77
from types import SimpleNamespace
8-
import unittest.mock
98

109
from cycler import cycler
1110
import numpy as np
@@ -96,16 +95,8 @@ def test_valid_linestyles():
9695
@mpl.style.context('mpl20')
9796
def test_zero_linewidth_dashed_uses_solid_gc_dashes():
9897
fig, ax = plt.subplots()
99-
line, = ax.plot([0, 1], [0, 1], ls='--', lw=0)
100-
renderer = fig.canvas.get_renderer()
101-
with unittest.mock.patch(
102-
"matplotlib.backend_bases.GraphicsContextBase.set_dashes",
103-
autospec=True,
104-
wraps=matplotlib.backend_bases.GraphicsContextBase.set_dashes,
105-
) as set_dashes:
106-
line.draw(renderer)
107-
108-
assert set_dashes.call_args_list[-1].args[1:] == (0, None)
98+
ax.plot([0, 1], [0, 1], ls='--', lw=0)
99+
fig.draw_without_rendering()
109100

110101

111102
@image_comparison(['drawstyle_variants.png'], remove_text=True,

lib/matplotlib/tests/test_patches.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Tests specific to the patches module.
33
"""
44
import platform
5-
import unittest.mock
65

76
import numpy as np
87
from numpy.testing import assert_almost_equal, assert_array_equal
@@ -910,18 +909,10 @@ def test_default_linestyle():
910909

911910
@mpl.style.context('mpl20')
912911
def test_patch_zero_linewidth_dashed_uses_solid_gc_dashes():
913-
_, ax = plt.subplots()
914-
rect = Rectangle((0, 0), 1, 1, fill=False, linewidth=0, linestyle='--')
915-
ax.add_patch(rect)
916-
renderer = ax.figure.canvas.get_renderer()
917-
with unittest.mock.patch(
918-
"matplotlib.backend_bases.GraphicsContextBase.set_dashes",
919-
autospec=True,
920-
wraps=mpl.backend_bases.GraphicsContextBase.set_dashes,
921-
) as set_dashes:
922-
rect.draw(renderer)
923-
924-
assert set_dashes.call_args_list[-1].args[1:] == (0, None)
912+
fig, ax = plt.subplots()
913+
ax.add_patch(Rectangle(
914+
(0, 0), 1, 1, fill=False, linewidth=0, linestyle='--'))
915+
fig.draw_without_rendering()
925916

926917

927918
def test_default_capstyle():

0 commit comments

Comments
 (0)