8000 Added direct test of _parse method to attempt to make Codecov happy. · matplotlib/matplotlib@9601975 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9601975

Browse files
committed
Added direct test of _parse method to attempt to make Codecov happy.
1 parent fcf6ce2 commit 9601975

File tree

1 file changed

+49
-18
lines changed

1 file changed

+49
-18
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,24 +2779,6 @@ def test_scatter_color_warning(self, kwargs):
27792779
plt.scatter([], [], c=[], **kwargs)
27802780
plt.scatter([1, 2], [3, 4], c=[4, 5], **kwargs)
27812781

2782-
@pytest.mark.parametrize('colors',
2783-
[
2784-
('red', 'blue'),
2785-
(['red', 'blue'], ['green', 'yellow']),
2786-
([[1, 0, 0], [0, 1, 0]], [[0, 0, 1], [1, 1, 0]])
2787-
])
2788-
def test_scatter_c_facecolor_warning(self, colors):
2789-
warn_match = (
2790-
"You passed both c and facecolor/facecolors for the markers. "
2791-
"c has precedence over facecolor/facecolors. This behavior may "
2792-
"change in the future."
2793-
)
2794-
fig, ax = plt.subplots()
2795-
x = [0, 1] if len(colors[0]) == 2 else [0]
2796-
y = x
2797-
with pytest.warns(UserWarning, match=warn_match):
2798-
ax.scatter(x, y, c=colors[0], facecolors=colors[1])
2799-
28002782
def test_scatter_unfilled(self):
28012783
coll = plt.scatter([0, 1, 2], [1, 3, 2], c=['0.1', '0.3', '0.5'],
28022784
marker=mmarkers.MarkerStyle('o', fillstyle='none'),
@@ -3080,6 +3062,55 @@ def get_next_color():
30803062
c, None, kwargs={}, xsize=2, get_next_color_func=get_next_color)
30813063

30823064

3065+
# Warning message tested in the next two tests.
3066+
WARN_MSG = (
3067+
"You passed both c and facecolor/facecolors for the markers. "
3068+
"c has precedence over facecolor/facecolors. This behavior may "
3069+
"change in the future."
3070+
)
3071+
# Test cases shared between direct and integration tests
3072+
COLOR_TEST_CASES = [
3073+
('red', 'blue'),
3074+
(['red', 'blue'], ['green', 'yellow']),
3075+
([[1, 0, 0], [0, 1, 0]], [[0, 0, 1], [1, 1, 0]])
3076+
]
3077+
3078+
3079+
@pytest.mark.parametrize('c, facecolor', COLOR_TEST_CASES)
3080+
def test_parse_c_facecolor_warning_direct(c, facecolor):
3081+
"""Test the internal _parse_scatter_color_args method directly."""
3082+
def get_next_color():
3083+
return 'blue'
3084+
3085+
# Test with facecolors (plural)
3086+
with pytest.warns(UserWarning, match=WARN_MSG):
3087+
mpl.axes.Axes._parse_scatter_color_args(
3088+
c=c, edgecolors=None, kwargs={'facecolors': facecolor},
3089+
xsize=2, get_next_color_func=get_next_color)
3090+
3091+
# Test with facecolor (singular)
3092+
with pytest.warns(UserWarning, match=WARN_MSG):
3093+
mpl.axes.Axes._parse_scatter_color_args(
3094+
c=c, edgecolors=None, kwargs={'facecolor': facecolor},
3095+
xsize=2, get_next_color_func=get_next_color)
3096+
3097+
3098+
@pytest.mark.parametrize('c, facecolor', COLOR_TEST_CASES)
3099+
def test_scatter_c_facecolor_warning_integration(c, facecolor):
3100+
"""Test the warning through the actual scatter plot creation."""
3101+
fig, ax = plt.subplots()
3102+
x = [0, 1] if isinstance(c, (list, tuple)) else [0]
3103+
y = x
3104+
3105+
# Test with facecolors (plural)
3106+
with pytest.warns(UserWarning, match=WARN_MSG):
3107+
ax.scatter(x, y, c=c, facecolors=facecolor)
3108+
3109+
# Test with facecolor (singular)
3110+
with pytest.warns(UserWarning, match=WARN_MSG):
3111+
ax.scatter(x, y, c=c, facecolor=facecolor)
3112+
3113+
30833114
def test_as_mpl_axes_api():
30843115
# tests the _as_mpl_axes api
30853116
class Polar:

0 commit comments

Comments
 (0)
0