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

Skip to content

Commit 9720e02

Browse files
authored
Merge pull request #18062 from dstansby/patch-cov
Bump matplotlib.patches coverage
2 parents 0339042 + ec0d9e7 commit 9720e02

1 file changed

Lines changed: 42 additions & 2 deletions

File tree

lib/matplotlib/tests/test_patches.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
from numpy.testing import assert_almost_equal, assert_array_equal
66
import pytest
77

8-
from matplotlib.patches import Polygon, Rectangle, FancyArrowPatch
8+
from matplotlib.patches import Patch, Polygon, Rectangle, FancyArrowPatch
99
from matplotlib.testing.decorators import image_comparison, check_figures_equal
1010
from matplotlib.transforms import Bbox
1111
import matplotlib.pyplot as plt
1212
from matplotlib import (
1313
collections as mcollections, colors as mcolors, patches as mpatches,
14-
path as mpath, style as mstyle, transforms as mtransforms)
14+
path as mpath, style as mstyle, transforms as mtransforms, rcParams)
1515

1616
import sys
1717
on_win = (sys.platform == 'win32')
@@ -563,3 +563,43 @@ def test_degenerate_polygon():
563563
point = [0, 0]
564564
correct_extents = Bbox([point, point]).extents
565565
assert np.all(Polygon([point]).get_extents().extents == correct_extents)
566+
567+
568+
@pytest.mark.parametrize('kwarg', ('edgecolor', 'facecolor'))
569+
def test_color_override_warning(kwarg):
570+
with pytest.warns(UserWarning,
571+
match="Setting the 'color' property will override "
572+
"the edgecolor or facecolor properties."):
573+
Patch(color='black', **{kwarg: 'black'})
574+
575+
576+
def test_empty_verts():
577+
poly = Polygon(np.zeros((0, 2)))
578+
assert poly.get_verts() == []
579+
580+
581+
def test_default_antialiased():
582+
patch = Patch()
583+
584+
patch.set_antialiased(not rcParams['patch.antialiased'])
585+
assert patch.get_antialiased() == (not rcParams['patch.antialiased'])
586+
# Check that None resets the state
587+
patch.set_antialiased(None)
588+
assert patch.get_antialiased() == rcParams['patch.antialiased']
589+
590+
591+
def test_default_linestyle():
592+
patch = Patch()
593+
patch.set_linestyle('--')
594+
patch.set_linestyle(None)
595+
assert patch.get_linestyle() == 'solid'
596+
597+
598+
def test_default_capstyle():
599+
patch = Patch()
600+
assert patch.get_capstyle() == 'butt'
601+
602+
603+
def test_default_joinstyle():
604+
patch = Patch()
605+
assert patch.get_joinstyle() == 'miter'

0 commit comments

Comments
 (0)