def test_bad_msg(self):
     decorated = Log('aaa {bbb} ccc')(foo)
     condition, msg = decorated._evaluate_expressions(None, None, 1, name='my name')
     self.assertTrue(condition)
     self.assertEquals('aaa {error:bbb} ccc', msg)
 def test_bad_condition(self):
     decorated = Log('aaa', '!@#$%')(foo)
     condition, msg = decorated._evaluate_expressions(None, None, 1, name='my name')
     self.assertTrue(condition)
     self.assertEquals('Invalid condition: !@#$%.', msg)
 def test_extra_kw_in_msg(self):
     decorated = Log('aaa {ret} bbb')(foo)
     _, msg = decorated._evaluate_expressions('111', None, 1, name='my name')
     self.assertEquals('aaa 111 bbb', msg)
 def test_extra_kw_in_condition(self):
     decorated = Log('aaa', 'ret')(foo)
     condition, _ = decorated._evaluate_expressions([1], {'name': 'my name'}, {'ret': True})
     self.assertTrue(condition)
 def test_condition_false(self):
     decorated = Log('aaa', '1 == 2')(foo)
     condition, msg = decorated._evaluate_expressions(None, None, 1, name='my name')
     self.assertFalse(condition)
     self.assertIsNone(msg)
 def test_condition_true(self):
     decorated = Log('aaa', '1 == 1')(foo)
     condition, msg = decorated._evaluate_expressions(None, None, 1, name='my name')
     self.assertTrue(condition)
     self.assertEquals('aaa', msg)