def testFlatmapFailsNonNestedList(self): """Test that passing Flatmap a sequence that does not contain nested iterables raises a TypeError.""" data = [1, 2] iterator = it.flatmap(lambda e: e, data) self.assertRaises(TypeError, next, iterator)
def testFlatmapWithNone(self): """Test that calling Flatmap with function as None results a TypeError.""" result = it.flatmap(None, [1, 2, 3]) self.assertRaises(TypeError, next, result)
def testFlatmapReturnsFlatList(self): """Test that using Flatmap with a sequence of nested sequences result in a flat list.""" allauthors = it.flatmap(lambda book: book.authors, self.books) knowngood = ['a', 'b', 'c'] self.assertEqual(list(allauthors), knowngood)