Exemple #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
Exemple #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
Exemple #3
0
 def __init__(self, *paths):
     self.paths = map(str, flatten(paths))
     self.path = '/'.join(self.paths)
     self.context = {}
Exemple #4
0
 def __init__(self, *paths):
     self.paths = map(str, flatten(paths))
     self.path = '/'.join(self.paths)
     self.context = {}