MCPcopy Index your code
hub / github.com/datacamp/pythonwhat / check_part

Function check_part

pythonwhat/checks/check_funcs.py:45–64  ·  view source on GitHub ↗

Return child state with name part as its ast tree

(state, name, part_msg, missing_msg=None, expand_msg=None)

Source from the content-addressed store, hash-verified

43
44
45def check_part(state, name, part_msg, missing_msg=None, expand_msg=None):
46 """Return child state with name part as its ast tree"""
47
48 if missing_msg is None:
49 missing_msg = "Are you sure you defined the {{part}}? "
50 if expand_msg is None:
51 expand_msg = "Did you correctly specify the {{part}}? "
52
53 if not part_msg:
54 part_msg = name
55 append_message = FeedbackComponent(expand_msg, {"part": part_msg})
56
57 has_part(state, name, missing_msg, append_message.kwargs)
58
59 stu_part = state.student_parts[name]
60 sol_part = state.solution_parts[name]
61
62 assert_ast(state, sol_part, append_message.kwargs)
63
64 return part_to_child(stu_part, sol_part, append_message, state)
65
66
67def check_part_index(state, name, index, part_msg, missing_msg=None, expand_msg=None):

Callers 8

test_if_elseFunction · 0.90
test_for_loopFunction · 0.90
test_while_loopFunction · 0.90
test_function_definitionFunction · 0.90
test_argsFunction · 0.90
test_withFunction · 0.90
test_compFunction · 0.90
check_argsFunction · 0.85

Calls 3

has_partFunction · 0.90
assert_astFunction · 0.90
part_to_childFunction · 0.85

Tested by 7

test_if_elseFunction · 0.72
test_for_loopFunction · 0.72
test_while_loopFunction · 0.72
test_function_definitionFunction · 0.72
test_argsFunction · 0.72
test_withFunction · 0.72
test_compFunction · 0.72