def test_formula_parser_method_call_with_args_and_kwargs_expr(self): to_e = lambda f:formula_parser.tree_to_expr(formula_parser.parse(f)) assert to_e('A.some_method("string", some_setting=True)') == \ "some_method(A,'string',some_setting=True)" assert to_e('A.some_method(some_setting=True)') == \ "some_method(A,some_setting=True)"
def test_formula_parser_method_call_with_dict_expr(self): to_e = lambda f:formula_parser.tree_to_expr(formula_parser.parse(f)) assert to_e('A.some_method({\'some dimension\':\'XYZ\'})') == \ "some_method(A,{'some dimension':'XYZ'})"
def test_formula_parser_method_call_with_args_expr(self): to_e = lambda f:formula_parser.tree_to_expr(formula_parser.parse(f)) assert to_e('A.some_method("string", B, 1, 2.3, (1, 2, 3))') == \ "some_method(A,'string',B,1,2.3,(1,2,3))"
def test_formula_parser_basic_method_call_expr(self): to_e = lambda f:formula_parser.tree_to_expr(formula_parser.parse(f)) assert 'prev_period(A)' == to_e('A.prev_period()')
def test_formula_parser_nested_parens_expr(self): to_e = lambda f:formula_parser.tree_to_expr(formula_parser.parse(f)) assert to_e('A*B/(A+B)') == 'div(mult(A,B),add(A,B))'
def test_formula_parser_simple_arithmetic_to_expr(self): to_e = lambda f:formula_parser.tree_to_expr(formula_parser.parse(f)) assert 'add(A,B)' == to_e('A+B') assert 'mult(A,B)' == to_e('A*B') assert 'div(A,B)' == to_e('A/B') assert 'sub(A,B)' == to_e('A-B')