Exemplo n.º 1
0
def test_flatten():
    tests = [(([1, 2, 3], ), [1, 2, 3]), (([1, [2, 3]], ), [1, 2, 3]),
             (([1, [2, [3]]], ), [1, 2, 3]),
             (([1, [2, [3], 4], 5, 6], ), [1, 2, 3, 4, 5, 6]),
             ((['foo', 'bar'], ), ['foo', 'bar']),
             ((['ab', 'cd'], ()), ['a', 'b', 'c', 'd'])]
    for args, result in tests:
        Assert(list(flatten(*args))) == result
Exemplo n.º 2
0
def test_flatten():
    tests = [
        (([1, 2, 3], ), [1, 2, 3]),
        (([1, [2, 3]], ), [1, 2, 3]),
        (([1, [2, [3]]], ), [1, 2, 3]),
        (([1, [2, [3], 4], 5, 6], ), [1, 2, 3, 4, 5, 6]),
        ((['foo', 'bar'], ), ['foo', 'bar']),
        ((['ab', 'cd'], ()), ['a', 'b', 'c', 'd'])
    ]
    for args, result in tests:
        Assert(list(flatten(*args))) == result
Exemplo n.º 3
0
 def __init__(self, *paths):
     self.paths = map(str, flatten(paths))
     self.path = '/'.join(self.paths)
     self.context = {}
Exemplo n.º 4
0
Arquivo: recipes.py Projeto: dag/rag
 def __init__(self, *paths):
     self.paths = map(str, flatten(paths))
     self.path = '/'.join(self.paths)
     self.context = {}