Beispiel #1
0
    def test_func_val_replace(self):

        argless = mapCmd.mapCmd({0: (lambda: 'spam', [])}, offset=0)
        self.assertEqual(argless[0](['x']), 'spam')

        arged = mapCmd.mapCmd({0: ((lambda x: 'spam'), [0])})
        self.assertEqual(arged[0](['x']), 'spam')

        cmd = mapCmd.mapCmd({0: ((lambda x: x + 2), [0])})
        self.assertEqual(cmd[0]([2]), 4)
Beispiel #2
0
 def test_func_val_names(self):
     cmd = mapCmd.mapCmd({'A': ((lambda x: x + 2), ['B'])}, str_is_name=True)
     self.assertEqual(cmd[0]([1,2,3,4]), 4)
Beispiel #3
0
 def test_func_val_offset(self): 
     cmd = mapCmd.mapCmd({1: ((lambda x: x + 2), [2])}, offset=1)
     self.assertEqual(cmd[0]([1,2,3,4]), 4)
Beispiel #4
0
 def test_value_val_replace(self):
     cmd = mapCmd.mapCmd({0: 'spam'})
     self.assertEqual(cmd[0](['x']), 'spam')
Beispiel #5
0
 def test_index_val_replace(self):
     cmd = mapCmd.mapCmd({0: 0})
     self.assertEqual(cmd[0](['x']), 'x')
Beispiel #6
0
 def test_name_val_replace(self):
     cmd = mapCmd.mapCmd({'a': 0})
     self.assertEqual(cmd[0](['x']), 'x')
Beispiel #7
0
 def test_invalid_key(self):
     with self.assertRaises(TypeError):
         mapCmd.mapCmd({(1, 2): 0}, str_is_name=True, int_is_index=True)
Beispiel #8
0
 def test_name_key_offset(self):
     cmd = mapCmd.mapCmd({'A': 1, 2: 'B'}, 
                         str_is_name=True,
                         offset=1)
     self.assertEqual([0, 1], list(cmd))
Beispiel #9
0
 def test_name_key_replace(self):
     cmd = mapCmd.mapCmd({'A': 0, 1: 'B'}, str_is_name=True)
     self.assertEqual([0, 1], list(cmd))
Beispiel #10
0
 def test_index_key_offset(self):
     cmd = mapCmd.mapCmd({1: 1}, offset=1)
     self.assertEqual([0], list(cmd))
Beispiel #11
0
 def test_index_key(self):
     cmd = mapCmd.mapCmd({0: 0})
     self.assertEqual([0], list(cmd))