def testFlattenSkipTypeOfSubclass(): class Foo(ListWithoutIter): def __init__(self, *args, **kwargs): super(Foo, self).__init__(*args, **kwargs) obj = Foo() a = [obj, "c", "d"] assert Flatten(a, skip_types=[ListWithoutIter]) == [obj, "c", "d"]
def testFlattenSkipSpecificClass(): obj = ListWithoutIter("a", "b") a = [obj, "c", ["d", "e"]] assert Flatten(a, skip_types=[ListWithoutIter]) == [obj, "c", "d", "e"]
def testFlattenForTuples(): a = [(0, "a"), (1, "b"), ((2, "c"), 42)] assert Flatten(a) == [0, "a", 1, "b", 2, "c", 42]
def testFlattenForUnicodeStrings(): a = [["a", "bb"], "ccc"] assert Flatten(a) == ["a", "bb", "ccc"]
def testFlattenOnClassWithoutIterForStrings(): a = ListWithoutIter(ListWithoutIter("a", "bb"), "ccc") assert Flatten(a) == ["a", "bb", "ccc"]
def testFlattenOnClassWithoutIter(): a = ListWithoutIter(ListWithoutIter(0, 1), 2, 3) assert Flatten(a) == [0, 1, 2, 3]
def testFlatten(): 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]