def keys_from_keydict(self, keydict):
     if not keydict:
         yield '_all'
         raise StopIteration
     idx_key_parts = sorted(keydict.keys())
     # Make sure all values are lists
     values = []
     for k in idx_key_parts:
         value = keydict[k]
         if not isinstance(value, (list, tuple)):
             value = [value]
         values.append([unicode(v).encode('utf-8') for v in value])
     for value_permutation in permutations(values):
         yield '-'.join(idx_key_parts + value_permutation)
Beispiel #2
0
 def keys_from_keydict(self, keydict):
     if not keydict:
         yield '_all'
         raise StopIteration
     idx_key_parts = sorted(keydict.keys())
     # Make sure all values are lists
     values = []
     for k in idx_key_parts:
         value = keydict[k]
         if not isinstance(value, (list, tuple)):
             value = [value]
         values.append([unicode(v).encode('utf-8') for v in value])
     for value_permutation in permutations(values):
         yield '-'.join(idx_key_parts + value_permutation)
Beispiel #3
0
 def test_multiple_permutations(self):
     vals = [[1, 2, 3], [4, 5], [6, 7]]
     self.assertEqual(list(permutations(vals)), [
         [1, 4, 6],
         [2, 4, 6],
         [3, 4, 6],
         [1, 5, 6],
         [2, 5, 6],
         [3, 5, 6],
         [1, 4, 7],
         [2, 4, 7],
         [3, 4, 7],
         [1, 5, 7],
         [2, 5, 7],
         [3, 5, 7],
     ])
Beispiel #4
0
 def test_multiple_permutations(self):
     vals = [[1, 2, 3], [4, 5], [6, 7]]
     self.assertEqual(
         list(permutations(vals)),
         [
             [1, 4, 6],
             [2, 4, 6],
             [3, 4, 6],
             [1, 5, 6],
             [2, 5, 6],
             [3, 5, 6],
             [1, 4, 7],
             [2, 4, 7],
             [3, 4, 7],
             [1, 5, 7],
             [2, 5, 7],
             [3, 5, 7],
         ]
     )
Beispiel #5
0
 def test_double_permutation(self):
     vals = [['1', '2']]
     self.assertEqual(list(permutations(vals)), [['1'], ['2']])
Beispiel #6
0
 def test_single_permutation(self):
     vals = [['asdf']]
     self.assertEqual(list(permutations(vals)), [['asdf']])
Beispiel #7
0
 def test_double_permutation(self):
     vals = [['1', '2']]
     self.assertEqual(list(permutations(vals)), [['1'], ['2']])
Beispiel #8
0
 def test_single_permutation(self):
     vals = [['asdf']]
     self.assertEqual(list(permutations(vals)), [['asdf']])