from pkg_resources import iter_entry_points


def mock_iter_entry_points_factory(data, mocked_group):
    """Create a mock iter_entry_points function."""

    def entrypoints(group, name=None):
        if group == mocked_group:
            for entrypoint in data:
                yield entrypoint
        else:
            for x in iter_entry_points(group=group, name=name):
                yield x
    return entrypoints