5050# the tests with multiple threads.
5151
5252
53+ def get_next_color ():
54+ """
55+ Helper function for tests that need to call _parse_scatter_color_args directly.
56+ Previously it was inserted in individual tests and would get flagged as untested.
57+ """
58+ return 'blue'
59+
60+
61+ def test_get_next_color ():
62+ result = mpl .axes .Axes ._parse_scatter_color_args (
63+ c = None ,
64+ edgecolors = None ,
65+ kwargs = {},
66+ xsize = 2 ,
67+ get_next_color_func = get_next_color
68+ )
69+ assert result .colors == 'blue'
70+
71+
5372@check_figures_equal (extensions = ["png" ])
5473def test_invisible_axes (fig_test , fig_ref ):
5574 ax = fig_test .subplots ()
@@ -2905,9 +2924,6 @@ def test_scatter_different_shapes(self, fig_test, fig_ref):
29052924
29062925 @pytest .mark .parametrize ('c_case, re_key' , params_test_scatter_c )
29072926 def test_scatter_c (self , c_case , re_key ):
2908- def get_next_color ():
2909- return 'blue' # currently unused
2910-
29112927 xsize = 4
29122928 # Additional checking of *c* (introduced in #11383).
29132929 REGEXP = {
@@ -2999,9 +3015,6 @@ def _params(c=None, xsize=2, *, edgecolors=None, **kwargs):
29993015 _result (c = ['b' , 'g' ], colors = np .array ([[0 , 0 , 1 , 1 ], [0 , .5 , 0 , 1 ]]))),
30003016 ])
30013017def test_parse_scatter_color_args (params , expected_result ):
3002- def get_next_color ():
3003- return 'blue' # currently unused
3004-
30053018 c , colors , _edgecolors = mpl .axes .Axes ._parse_scatter_color_args (
30063019 * params , get_next_color_func = get_next_color )
30073020 assert c == expected_result .c
@@ -3026,9 +3039,6 @@ def get_next_color():
30263039 (dict (color = 'r' , edgecolor = 'g' ), 'g' ),
30273040 ])
30283041def test_parse_scatter_color_args_edgecolors (kwargs , expected_edgecolors ):
3029- def get_next_color ():
3030- return 'blue' # currently unused
3031-
30323042 c = kwargs .pop ('c' , None )
30333043 edgecolors = kwargs .pop ('edgecolors' , None )
30343044 _ , _ , result_edgecolors = \
@@ -3038,9 +3048,6 @@ def get_next_color():
30383048
30393049
30403050def test_parse_scatter_color_args_error ():
3041- def get_next_color ():
3042- return 'blue' # currently unused
3043-
30443051 with pytest .raises (ValueError ,
30453052 match = "RGBA values should be within 0-1 range" ):
30463053 c = np .array ([[0.1 , 0.2 , 0.7 ], [0.2 , 0.4 , 1.4 ]]) # value > 1
@@ -3065,20 +3072,17 @@ def get_next_color():
30653072@pytest .mark .parametrize ('c, facecolor' , COLOR_TEST_CASES )
30663073def test_parse_c_facecolor_warning_direct (c , facecolor ):
30673074 """Test the internal _parse_scatter_color_args method directly."""
3068- def get_next_color ():
3069- return 'blue'
3070-
30713075 # Test with facecolors (plural)
30723076 with pytest .warns (UserWarning , match = WARN_MSG ):
30733077 mpl .axes .Axes ._parse_scatter_color_args (
30743078 c = c , edgecolors = None , kwargs = {'facecolors' : facecolor },
3075- xsize = 2 , get_next_color_func = get_next_color )
3079+ xsize = 2 , get_next_color_func = get_next_color () )
30763080
30773081 # Test with facecolor (singular)
30783082 with pytest .warns (UserWarning , match = WARN_MSG ):
30793083 mpl .axes .Axes ._parse_scatter_color_args (
30803084 c = c , edgecolors = None , kwargs = {'facecolor' : facecolor },
3081- xsize = 2 , get_next_color_func = get_next_color )
3085+ xsize = 2 , get_next_color_func = get_next_color () )
30823086
30833087
30843088@pytest .mark .parametrize ('c, facecolor' , COLOR_TEST_CASES )
@@ -9057,9 +9061,6 @@ def test_child_axes_removal():
90579061
90589062
90599063def test_scatter_color_repr_error ():
9060-
9061- def get_next_color ():
9062- return 'blue' # pragma: no cover
90639064 msg = (
90649065 r"'c' argument must be a color, a sequence of colors"
90659066 r", or a sequence of numbers, not 'red\\n'"
0 commit comments