示例#1
0
文件: logic.py 项目: notanumber/south
 def test_flatten(self):
     self.assertEqual([], list(flatten(iter([]))))
     self.assertEqual([], list(flatten(iter([iter([])]))))
     self.assertEqual([1], list(flatten(iter([1]))))
     self.assertEqual([1, 2], list(flatten(iter([1, 2]))))
     self.assertEqual([1, 2], list(flatten(iter([iter([1]), 2]))))
     self.assertEqual([1, 2], list(flatten(iter([iter([1, 2])]))))
     self.assertEqual([1, 2, 3], list(flatten(iter([iter([1, 2]), 3]))))
     self.assertEqual([1, 2, 3], list(flatten(iter([iter([1]), iter([2]), 3]))))
     self.assertEqual([1, 2, 3], list(flatten([[1], [2], 3])))
示例#2
0
 def test_flatten(self):
     self.assertEqual([], list(flatten(iter([]))))
     self.assertEqual([], list(flatten(iter([iter([]), ]))))
     self.assertEqual([1], list(flatten(iter([1]))))
     self.assertEqual([1, 2], list(flatten(iter([1, 2]))))
     self.assertEqual([1, 2], list(flatten(iter([iter([1]), 2]))))
     self.assertEqual([1, 2], list(flatten(iter([iter([1, 2])]))))
     self.assertEqual([1, 2, 3], list(flatten(iter([iter([1, 2]), 3]))))
     self.assertEqual([1, 2, 3],
                      list(flatten(iter([iter([1]), iter([2]), 3]))))
     self.assertEqual([1, 2, 3],
                      list(flatten([[1], [2], 3])))