def test_eval_with_symbol_kwarg(self): func = mock.Mock(return_value='return value') del func._eval # So it doesn't pretend to be symbolic expr = Call( func, ('arg1', 'arg2'), {'kwarg_name': Symbol('some_symbol')}) result = expr._eval({'some_symbol': 'kwarg value'}) func.assert_called_once_with('arg1', 'arg2', kwarg_name='kwarg value') self.assertEqual(result, 'return value')
def test_eval_with_nonsymbolic_func(self): func = mock.Mock(return_value='return value') del func._eval # So it doesn't pretend to be symbolic expr = Call(func, ('arg1', 'arg2'), {'kwarg_name': 'kwarg value'}) # Ensure constructing the expression does not call the function self.assertFalse(func.called) result = expr._eval({}) func.assert_called_once_with('arg1', 'arg2', kwarg_name='kwarg value') self.assertEqual(result, 'return value')