示例#1
0
 def test_def_value(self):
   x = ExpressionDict({'t': 'true', 'f': 'false',
                       'def': '${unknown:true}', 'indirect': '${f}'})
   x.default_value_interpreter = lambda x: True if x == 'true' else False if x == 'false' else x
   self.assertEqual('true', x.get('t'))
   self.assertEqual('false', x.get('f'))
   self.assertEqual(True, x.get('def'))
   self.assertEqual('false', x.get('indirect'))
示例#2
0
 def test_def_value(self):
     x = ExpressionDict({
         't': 'true',
         'f': 'false',
         'def': '${unknown:true}',
         'indirect': '${f}'
     })
     x.default_value_interpreter = lambda x: True if x == 'true' else False if x == 'false' else x
     self.assertEqual('true', x.get('t'))
     self.assertEqual('false', x.get('f'))
     self.assertEqual(True, x.get('def'))
     self.assertEqual('false', x.get('indirect'))
 def test_def_value(self):
     x = ExpressionDict({
         "t": "true",
         "f": "false",
         "def": "${unknown:true}",
         "indirect": "${f}"
     })
     x.default_value_interpreter = (lambda x: True if x == "true" else False
                                    if x == "false" else x)
     self.assertEqual("true", x.get("t"))
     self.assertEqual("false", x.get("f"))
     self.assertEqual(True, x.get("def"))
     self.assertEqual("false", x.get("indirect"))