Beispiel #1
0
def generate_plist(function, start=0):
    """
    Generates a parallel list of random size between 1 and 111, or an empty list,
    using ``function`` to initialize the elements of the list. If ``start`` is 1,
    a non-empty parallel list is generated.

    :param function: callable
    :param start: int (0 or 1)
    :return: PList
    """
    choice = randint(start, 2)
    size = randint(1, 111)
    if choice == 0:
        return PList()
    if choice == 1:
        return PList.init(function, size)
    return PList.from_seq([function(i) for i in range(0, size)])
Beispiel #2
0
def test_zip_empty():
    # pylint: disable=missing-docstring
    data = PList()
    res = data.zip(data).to_seq()
    exp = []
    assert res == exp
Beispiel #3
0
def test_mapi_empty():
    # pylint: disable=missing-docstring
    data = PList()
    res = data.mapi(pos_upper).to_seq()
    exp = []
    assert res == exp
Beispiel #4
0
def test_map2_empty():
    # pylint: disable=missing-docstring
    data = PList()
    res = data.map2(operator.add, data).to_seq()
    exp = []
    assert res == exp
Beispiel #5
0
def test_init_to_seq_empty():
    # pylint: disable=missing-docstring
    plst = PList()
    res = plst.to_seq()
    exp = []
    assert res == exp