Exemple #1
0
    def testGenerator(self):
        def Foo():
            yield 1, "foo"
            yield 2, "bar"
            yield 3, "baz"

        left, right = collection.Unzip(Foo())
        self.assertSequenceEqual(left, [1, 2, 3])
        self.assertSequenceEqual(right, ["foo", "bar", "baz"])
Exemple #2
0
 def testStrings(self):
   left, right = collection.Unzip(zip("fooquux", "barnorf"))
   self.assertSequenceEqual(left, "fooquux")
   self.assertSequenceEqual(right, "barnorf")
Exemple #3
0
 def testList(self):
   left, right = collection.Unzip([(1, 2), (3, 4), (5, 6)])
   self.assertSequenceEqual(left, [1, 3, 5])
   self.assertSequenceEqual(right, [2, 4, 6])
Exemple #4
0
 def testEmpty(self):
   left, right = collection.Unzip([])
   self.assertEmpty(left)
   self.assertEmpty(right)