Beispiel #1
0
 def _partition(obj):
     for s in flatten(obj):
         head, sep, tail = s.partition(separator)
         if normalize_head:
             head = normalize_head(head)
         if normalize_tail:
             tail = normalize_tail(tail)
         if sep:
             yield (head, tail)
Beispiel #2
0
def test_flatten():
    assert list(i.flatten([['a'], ['b']])) == ['a', 'b']
Beispiel #3
0
def test_flatten_nested():
    assert list(i.flatten([['a'], ['b', 'c']])) == ['a', 'b', 'c']
Beispiel #4
0
def test_flatten_string():
    # A string isn't considered iterable so nothing should happen
    assert list(i.flatten('abc')) == ['abc']
Beispiel #5
0
def test_flatten_nested():
    assert list(i.flatten([['a'], ['b', 'c']])) == ['a', 'b', 'c']
Beispiel #6
0
def test_flatten_string():
    # A string isn't considered iterable so nothing should happen
    assert list(i.flatten('abc')) == ['abc']
Beispiel #7
0
def test_flatten():
    assert list(i.flatten([['a'], ['b']])) == ['a', 'b']