예제 #1
0
    def testFlattenSkipTypeOfSubclass(self):
        class Foo(self.ListWithoutIter):
            def __init__(self, *args, **kwargs):
                super(Foo, self).__init__(*args, **kwargs)

        obj = Foo()
        a = [obj, 'c', 'd']
        assert Flatten(a, skip_types=[self.ListWithoutIter]) == [obj, 'c', 'd']
예제 #2
0
 def testFlattenForTuples(self):
     a = [(0, "a"), (1, "b"), ((2, "c"), 42)]
     assert Flatten(a) == [0, "a", 1, "b", 2, "c", 42]
예제 #3
0
 def testFlattenSkipSpecificClass(self):
     obj = self.ListWithoutIter('a', 'b')
     a = [obj, 'c', ['d', 'e']]
     assert Flatten(a, skip_types=[self.ListWithoutIter
                                   ]) == [obj, 'c', 'd', 'e']
예제 #4
0
 def testFlattenForUnicodeStrings(self):
     a = [[u"a", u"bb"], u"ccc"]
     assert Flatten(a) == [u"a", u"bb", u"ccc"]
예제 #5
0
 def testFlattenForStrings(self):
     a = [["a", "bb"], "ccc"]
     assert Flatten(a) == ["a", "bb", "ccc"]
예제 #6
0
 def testFlattenOnClassWithoutIterForStrings(self):
     a = self.ListWithoutIter(self.ListWithoutIter("a", "bb"), "ccc")
     assert Flatten(a) == ["a", "bb", "ccc"]
예제 #7
0
 def testFlattenOnClassWithoutIter(self):
     a = self.ListWithoutIter(self.ListWithoutIter(0, 1), 2, 3)
     assert Flatten(a) == [0, 1, 2, 3]
예제 #8
0
    def testFlatten(self):
        a = [[[1], [2]], [3]]
        assert Flatten(a) == [1, 2, 3]

        a = [1, 2, [3, 4], (5, 6)]
        assert Flatten(a) == [1, 2, 3, 4, 5, 6]