Esempio n. 1
0
 def test_shallow_dict(self):
     a = {'a': 1, 'b': 2, 'c': 3}
     b = {'a': 4, 'b': 5, 'c': 6}
     c = {'a': 7, 'b': 8, 'c': 9}
     result = nested.zip(a, b, c)
     self.assertEqual({
         'a': (1, 4, 7),
         'b': (2, 5, 8),
         'c': (3, 6, 9)
     }, result)
Esempio n. 2
0
 def test_namedtuple(self):
     Foo = collections.namedtuple('Foo', 'value')
     foo, bar = Foo(42), Foo(13)
     self.assertEqual(Foo((42, 13)), nested.zip(foo, bar))
Esempio n. 3
0
 def test_use_type_of_first(self):
     a = (1, 2, 3)
     b = [4, 5, 6]
     c = [7, 8, 9]
     result = nested.zip(a, b, c)
     self.assertEqual(((1, 4, 7), (2, 5, 8), (3, 6, 9)), result)
Esempio n. 4
0
 def test_different_types(self):
     a = [1, 2, 3]
     b = 'a b c'.split()
     result = nested.zip(a, b)
     self.assertEqual([(1, 'a'), (2, 'b'), (3, 'c')], result)
Esempio n. 5
0
 def test_mixed_structures(self):
     a = [(1, 2), 3, {'foo': [4]}]
     b = [(5, 6), 7, {'foo': [8]}]
     result = nested.zip(a, b)
     self.assertEqual([((1, 5), (2, 6)), (3, 7), {'foo': [(4, 8)]}], result)
Esempio n. 6
0
 def test_single(self):
     a = [[1, 2], 3]
     result = nested.zip(a)
     self.assertEqual(a, result)
Esempio n. 7
0
 def test_shallow_tuple(self):
     a = (1, 2, 3)
     b = (4, 5, 6)
     c = (7, 8, 9)
     result = nested.zip(a, b, c)
     self.assertEqual(((1, 4, 7), (2, 5, 8), (3, 6, 9)), result)
Esempio n. 8
0
 def test_shallow_list(self):
     a = [1, 2, 3]
     b = [4, 5, 6]
     c = [7, 8, 9]
     result = nested.zip(a, b, c)
     self.assertEqual([(1, 4, 7), (2, 5, 8), (3, 6, 9)], result)
Esempio n. 9
0
 def test_base_case(self):
     self.assertEqual((1, 2, 3), nested.zip(1, 2, 3))
Esempio n. 10
0
 def test_empty(self):
     self.assertEqual({}, nested.zip({}, {}))
Esempio n. 11
0
 def test_scalar(self):
     self.assertEqual(42, nested.zip(42))
     self.assertEqual((13, 42), nested.zip(13, 42))