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']
def testFlattenForTuples(self): a = [(0, "a"), (1, "b"), ((2, "c"), 42)] assert Flatten(a) == [0, "a", 1, "b", 2, "c", 42]
def testFlattenSkipSpecificClass(self): obj = self.ListWithoutIter('a', 'b') a = [obj, 'c', ['d', 'e']] assert Flatten(a, skip_types=[self.ListWithoutIter ]) == [obj, 'c', 'd', 'e']
def testFlattenForUnicodeStrings(self): a = [[u"a", u"bb"], u"ccc"] assert Flatten(a) == [u"a", u"bb", u"ccc"]
def testFlattenForStrings(self): a = [["a", "bb"], "ccc"] assert Flatten(a) == ["a", "bb", "ccc"]
def testFlattenOnClassWithoutIterForStrings(self): a = self.ListWithoutIter(self.ListWithoutIter("a", "bb"), "ccc") assert Flatten(a) == ["a", "bb", "ccc"]
def testFlattenOnClassWithoutIter(self): a = self.ListWithoutIter(self.ListWithoutIter(0, 1), 2, 3) assert Flatten(a) == [0, 1, 2, 3]
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]