Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)