|
5 | 5 | from numpy.testing import assert_almost_equal, assert_array_equal |
6 | 6 | import pytest |
7 | 7 |
|
8 | | -from matplotlib.patches import Polygon, Rectangle, FancyArrowPatch |
| 8 | +from matplotlib.patches import Patch, Polygon, Rectangle, FancyArrowPatch |
9 | 9 | from matplotlib.testing.decorators import image_comparison, check_figures_equal |
10 | 10 | from matplotlib.transforms import Bbox |
11 | 11 | import matplotlib.pyplot as plt |
12 | 12 | from matplotlib import ( |
13 | 13 | 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) |
15 | 15 |
|
16 | 16 | import sys |
17 | 17 | on_win = (sys.platform == 'win32') |
@@ -563,3 +563,43 @@ def test_degenerate_polygon(): |
563 | 563 | point = [0, 0] |
564 | 564 | correct_extents = Bbox([point, point]).extents |
565 | 565 | 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