示例#1
0
def test_flatten_callable():
    def x():
        return [1, 2, 3]

    y = [4, 5, x]

    assert list(flatten(y)) == [4, 5, 1, 2, 3]
示例#2
0
def test_flatten_callable():
    x = lambda: [1, 2, 3]
    y = [4, 5, x]

    assert list(flatten(y)) == [4, 5, 1, 2, 3]
示例#3
0
def test_flatten():
    l = [[1, 2, 3], [4], [[[5]]], 'ololo']

    assert list(flatten(l)) == [1, 2, 3, 4, 5, 'ololo']
示例#4
0
def test_flatten_callable():
    x = lambda: [1, 2, 3]
    y = [4, 5, x]

    assert list(flatten(y)) == [4, 5, 1, 2, 3]
示例#5
0
def test_flatten():
    l = [[1, 2, 3], [4], [[[5]]], 'ololo']

    assert list(flatten(l)) == [1, 2, 3, 4, 5, 'ololo']
示例#6
0
def test_flatten_function_returning_noniterable():
    def y():
        return 100

    assert list(flatten(y)) == [100]
示例#7
0
def test_flatten_noniterable():
    y = 100
    assert list(flatten(y)) == [y]