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"])
def testStrings(self): left, right = collection.Unzip(zip("fooquux", "barnorf")) self.assertSequenceEqual(left, "fooquux") self.assertSequenceEqual(right, "barnorf")
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])
def testEmpty(self): left, right = collection.Unzip([]) self.assertEmpty(left) self.assertEmpty(right)