本文整理汇总了Python中tests.util.asserts.assert_that函数的典型用法代码示例。如果您正苦于以下问题:Python assert_that函数的具体用法?Python assert_that怎么用?Python assert_that使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_that函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: The_str_of_a_value_is_its_repr
def The_str_of_a_value_is_its_repr():
@valueclass("m1", "m2", "m3")
class MyClass:
pass
x = MyClass(3, '4', 5)
assert_that(str(x), equals(repr(x)))
开发者ID:andybalaam,项目名称:cell,代码行数:7,代码来源:valueclass_tests.py
示例2: Function_definition_containing_commands_gets_parsed
def Function_definition_containing_commands_gets_parsed():
assert_that(
parsed('{print(3-4); a = "x"; print(a);};'),
equals(
[
(
"function",
[],
[
(
"call",
("symbol", 'print'),
[
(
"operation",
'-',
("number", '3'),
("number", '4')
)
]
),
("assignment", ("symbol", 'a'), ("string", 'x')),
("call", ("symbol", 'print'), [("symbol", 'a')])
]
)
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:28,代码来源:parser_tests.py
示例3: Multiple_function_calls_with_various_args_get_parsed
def Multiple_function_calls_with_various_args_get_parsed():
assert_that(
parsed("print( 'a', 3, 4 / 12 )(512)();"),
equals(
[
(
"call",
(
"call",
(
"call",
("symbol", "print"),
[
("string", "a"),
("number", "3"),
(
"operation",
"/",
("number", "4"),
("number", "12")
)
]
),
[
("number", "512")
]
),
[]
)
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:32,代码来源:parser_tests.py
示例4: A_closure_holds_updateable_values
def A_closure_holds_updateable_values():
def dumb_set(env, sym, val):
env.parent.parent.parent.set(sym[1], val)
def dumb_if_equal(env, val1, val2, then_fn, else_fn):
if val1 == val2:
ret = then_fn
else:
ret = else_fn
return eval_expr(("call", ret, []), env)
env = Env()
env.set("dumb_set", ("native", dumb_set))
env.set("dumb_if_equal", ("native", dumb_if_equal))
assert_that(
evald(
"""
counter = {
x = 0;
{:(meth)
dumb_if_equal(meth, "get",
{x;},
{dumb_set("x", x + 1);}
);
}
}();
counter("inc");
counter("inc");
counter("get");
""",
env
),
equals(("number", 2))
)
开发者ID:andybalaam,项目名称:cell,代码行数:33,代码来源:eval_tests.py
示例5: Multiple_commands_parse_into_multiple_expressions
def Multiple_commands_parse_into_multiple_expressions():
program = """
x = 3;
func = {:(a) print(a);};
func(x);
"""
assert_that(
parsed(program),
equals(
[
("assignment", ("symbol", 'x'), ("number", '3')),
(
"assignment",
("symbol", 'func'),
(
"function",
[("symbol", 'a')],
[
("call", ("symbol", 'print'), [("symbol", 'a')])
]
)
),
("call", ("symbol", 'func'), [("symbol", 'x')])
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:26,代码来源:parser_tests.py
示例6: Function_definition_with_params_and_commands_gets_parsed
def Function_definition_with_params_and_commands_gets_parsed():
assert_that(
parsed('{:(x,yy)print(3-4); a = "x"; print(a);};'),
equals(
[
(
"function",
[
("symbol", "x"),
("symbol", "yy")
],
[
(
"call",
("symbol", 'print'),
[
(
"operation",
'-',
("number", '3'),
("number", '4')
)
]
),
("assignment", ("symbol", 'a'), ("string", 'x')),
("call", ("symbol", 'print'), [("symbol", 'a')])
]
)
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:31,代码来源:parser_tests.py
示例7: Can_construct_a_nonempty_value_class_using_keyword_args
def Can_construct_a_nonempty_value_class_using_keyword_args():
@valueclass("mem1", "mem2")
class MyClass:
pass
b = MyClass(mem1=3, mem2=4)
assert_that(b.mem1, equals(3))
assert_that(b.mem2, equals(4))
开发者ID:andybalaam,项目名称:cell,代码行数:8,代码来源:valueclass_tests.py
示例8: Can_hold_a_reference_to_a_function_and_call_it
def Can_hold_a_reference_to_a_function_and_call_it():
assert_that(
evald("""
add = {:(x, y) x + y;};
add(20, 2.2);
"""),
equals(("number", 22.2))
)
开发者ID:andybalaam,项目名称:cell,代码行数:8,代码来源:eval_tests.py
示例9: Can_construct_a_nonempty_value_class_using_positional_args
def Can_construct_a_nonempty_value_class_using_positional_args():
@valueclass("mem1", "mem2")
class MyClass:
pass
b = MyClass(3, 4)
assert_that(b.mem1, equals(3))
assert_that(b.mem2, equals(4))
开发者ID:andybalaam,项目名称:cell,代码行数:8,代码来源:valueclass_tests.py
示例10: Function_call_with_no_args_gets_parsed
def Function_call_with_no_args_gets_parsed():
assert_that(
parsed("print();"),
equals(
[
("call", ("symbol", "print"), [])
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:parser_tests.py
示例11: Multiple_function_calls_with_no_args_get_parsed
def Multiple_function_calls_with_no_args_get_parsed():
assert_that(
parsed("print()();"),
equals(
[
("call", ("call", ("symbol", "print"), []), [])
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:parser_tests.py
示例12: A_native_function_can_edit_the_environment
def A_native_function_can_edit_the_environment():
def mx3(env):
env.set("x", ("number", 3))
env = Env()
env.set("make_x_three", ("native", mx3))
assert_that(
evald("x=1;make_x_three();x;", env),
equals(("number", 3))
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:eval_tests.py
示例13: A_symbol_within_a_function_has_the_local_value
def A_symbol_within_a_function_has_the_local_value():
assert_that(
evald("""
foo = 3;
bar = {foo = 77;foo;}();
bar;
"""),
equals(("number", 77))
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:eval_tests.py
示例14: Multiplication_of_symbols_is_parsed_as_expression
def Multiplication_of_symbols_is_parsed_as_expression():
assert_that(
parsed("foo * bar;"),
equals(
[
("operation", "*", ("symbol", "foo"), ("symbol", "bar"))
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:parser_tests.py
示例15: Variable_assignment_gets_parsed
def Variable_assignment_gets_parsed():
assert_that(
parsed("x = 3;"),
equals(
[
("assignment", ("symbol", "x"), ("number", "3"))
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:parser_tests.py
示例16: Difference_of_symbol_and_number_is_parsed_as_expression
def Difference_of_symbol_and_number_is_parsed_as_expression():
assert_that(
parsed("foo - 44;"),
equals(
[
("operation", "-", ("symbol", "foo"), ("number", "44"))
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:parser_tests.py
示例17: Sum_of_numbers_is_parsed_as_expression
def Sum_of_numbers_is_parsed_as_expression():
assert_that(
parsed("32 + 44;"),
equals(
[
("operation", "+", ("number", "32"), ("number", "44"))
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:parser_tests.py
示例18: Assigning_to_an_expression_is_an_error
def Assigning_to_an_expression_is_an_error():
try:
parsed("x(4) = 5;")
fail("Should throw")
except Exception as e:
assert_that(
str(e),
equals("You can't assign to anything except a symbol.")
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:parser_tests.py
示例19: Empty_function_definition_gets_parsed
def Empty_function_definition_gets_parsed():
assert_that(
parsed("{};"),
equals(
[
("function", [], [])
]
)
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:parser_tests.py
示例20: Missing_param_definition_with_colon_is_an_error
def Missing_param_definition_with_colon_is_an_error():
try:
parsed("{:print(x););")
fail("Should throw")
except Exception as e:
assert_that(
str(e),
equals("':' must be followed by '(' in a function.")
)
开发者ID:andybalaam,项目名称:cell,代码行数:9,代码来源:parser_tests.py
注:本文中的tests.util.asserts.assert_that函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论