예제 #1
0
 def testInitEquivPairs(self):
     otherEp = utilitytypes.EquivalencePairs({1: 'foo', 2: 'bar'})
     ep = utilitytypes.EquivalencePairs(otherEp)
     self.assertEqual(ep[1], 'foo')
     self.assertEqual(ep[2], 'bar')
     self.assertEqual(ep['foo'], 1)
     self.assertEqual(ep['bar'], 2)
예제 #2
0
 def testOverwritePairs(self):
     ep = utilitytypes.EquivalencePairs({1: 'a', 2: 'b'})
     self.assertEqual(ep[1], 'a')
     self.assertEqual(ep[2], 'b')
     self.assertEqual(ep['a'], 1)
     self.assertEqual(ep['b'], 2)
     ep[1] = 2
     self.assertRaises(KeyError, self._getIndex, ep, 'a')
     self.assertRaises(KeyError, self._getIndex, ep, 'b')
     self.assertEqual(ep[1], 2)
     self.assertEqual(ep[2], 1)
예제 #3
0
 def testInitDict(self):
     ep = utilitytypes.EquivalencePairs({1: 'foo', 2: 'bar'})
     self.assertEqual(ep[1], 'foo')
     self.assertEqual(ep[2], 'bar')
     self.assertEqual(ep['foo'], 1)
     self.assertEqual(ep['bar'], 2)
예제 #4
0
 def testInitPairs(self):
     ep = utilitytypes.EquivalencePairs(((1, 'foo'), (2, 'bar')))
     self.assertEqual(ep[1], 'foo')
     self.assertEqual(ep[2], 'bar')
     self.assertEqual(ep['foo'], 1)
     self.assertEqual(ep['bar'], 2)