Exemplo n.º 1
0
 def testCustomKey(self):
   data = [(i, hex(i), "test%s" % i) for i in range(100)]
   self.assertEqual(algo.SequenceToDict(data, key=compat.snd),
     dict((hex(i), (i, hex(i), "test%s" % i))
          for i in range(100)))
   self.assertEqual(algo.SequenceToDict(data,
                                        key=lambda a_b_val: hash(a_b_val[2])),
     dict((hash("test%s" % i), (i, hex(i), "test%s" % i))
          for i in range(100)))
Exemplo n.º 2
0
 def testSimple(self):
   data = [(i, str(i), "test%s" % i) for i in range(391)]
   self.assertEqual(algo.SequenceToDict(data),
     dict((i, (i, str(i), "test%s" % i))
          for i in range(391)))
Exemplo n.º 3
0
 def testEmpty(self):
   self.assertEqual(algo.SequenceToDict([]), {})
   self.assertEqual(algo.SequenceToDict({}), {})