Repository: matplotlib/matplotlib
File: lib/matplotlib/tests/test__style_helpers.py (Python)

Code before:
import pytest

import matplotlib.colors as mcolors
from matplotlib.lines import _get_dash_pattern
from matplotlib._style_helpers import style_generator


@pytest.mark.parametrize('key, value', [('facecolor', ["b", "g", "r"]),
                                        ('edgecolor', ["b", "g", "r"]),
                                        ('hatch', ["/", "\\", "."]),
                                        ('linestyle', ["-", "--", ":"]),
                                        ('linewidth', [1, 1.5, 2])])
def test_style_generator_list(key, value):
    kw = {'foo': 12, key: value}
    new_kw, gen = style_generator(kw)

    assert new_kw == {'foo': 12}

    for v in value * 2:  # Result should repeat
        style_dict = next(gen)
        assert len(style_dict) == 1
        if key.endswith('color'):
            assert mcolors.same_color(v, style_dict[key])
        elif key == 'linestyle':
            assert _get_dash_pattern(v) == style_dict[key]
        else:
            assert v == style_dict[key]


@pytest.mark.parametrize('key, value', [('facecolor', "b"),
                                        ('edgecolor', "b"),
                                        ('hatch', "/"),
                                        ('linestyle', "-"),
                                        ('linewidth', 1)])
def test_style_generator_single(key, value):
    kw = {'foo': 12, key: value}
    new_kw, gen = style_generator(kw)


Review comment (suggestion):
```suggestion
def test_style_generator_list(key, value):
    """Test that style parameter lists are distributed to the generator."""
```
or as similar wording.

Code after:
import pytest

import matplotlib.colors as mcolors
from matplotlib.lines import _get_dash_pattern
from matplotlib._style_helpers import style_generator


@pytest.mark.parametrize('key, value', [('facecolor', ["b", "g", "r"]),
                                        ('edgecolor', ["b", "g", "r"]),
                                        ('hatch', ["/", "\\", "."]),
                                        ('linestyle', ["-", "--", ":"]),
                                        ('linewidth', [1, 1.5, 2])])
def test_style_generator_list(key, value):
    """Test that style parameter lists are distributed to the generator."""
    kw = {'foo': 12, key: value}
    new_kw, gen = style_generator(kw)

    assert new_kw == {'foo': 12}

    for v in value * 2:  # Result should repeat
        style_dict = next(gen)
        assert len(style_dict) == 1
        if key.endswith('color'):
            assert mcolors.same_color(v, style_dict[key])
        elif key == 'linestyle':
            assert _get_dash_pattern(v) == style_dict[key]
        else:
            assert v == style_dict[key]


@pytest.mark.parametrize('key, value', [('facecolor', "b"),
                                        ('edgecolor', "b"),
                                        ('hatch', "/"),
                                        ('linestyle', "-"),
                                        ('linewidth', 1)])
def test_style_generator_single(key, value):
    """Test that single-value style parameters are distributed to the generator."""
    kw = {'foo': 12, key: value}