Skip to content

Commit fe2ed99

Browse files
committed
Improve child state creation compatibility with protowhat
1 parent 6158ed5 commit fe2ed99

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

pythonwhat/State.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def build_message(self, tail="", fmt_kwargs=None, append=True):
154154
def do_test(self, test):
155155
return self.reporter.do_test(test)
156156

157-
def to_child_state(
157+
def to_child(
158158
self,
159159
student_subtree=None,
160160
solution_subtree=None,
@@ -212,7 +212,7 @@ def to_child_state(
212212
messages = [*self.messages, append_message]
213213

214214
if not (solution_subtree and student_subtree):
215-
return self.update(
215+
return self._update(
216216
student_context=student_context,
217217
solution_context=solution_context,
218218
student_env=student_env,
@@ -250,7 +250,7 @@ def to_child_state(
250250
)
251251
return child
252252

253-
def update(self, **kwargs):
253+
def _update(self, **kwargs):
254254
"""Return a copy of set, setting kwargs as attributes"""
255255
child = copy(self)
256256
for k, v in kwargs.items():

pythonwhat/checks/check_funcs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def part_to_child(stu_part, sol_part, append_message, state, node_name=None):
2626

2727
# if the parts are dictionaries, use to deck out child state
2828
if all(isinstance(p, dict) for p in [stu_part, sol_part]):
29-
child_state = state.to_child_state(
29+
child_state = state.to_child(
3030
student_subtree=stu_part["node"],
3131
solution_subtree=sol_part["node"],
3232
student_context=stu_part.get("target_vars"),
@@ -39,7 +39,7 @@ def part_to_child(stu_part, sol_part, append_message, state, node_name=None):
3939
)
4040
else:
4141
# otherwise, assume they are just nodes
42-
child_state = state.to_child_state(
42+
child_state = state.to_child(
4343
student_subtree=stu_part,
4444
solution_subtree=sol_part,
4545
append_message=append_message,

pythonwhat/checks/check_has_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _test(state, incorrect_msg, exact_names, tv_name, highlight_name):
2020
stu_vars = state.student_parts[tv_name]
2121
sol_vars = state.solution_parts[tv_name]
2222

23-
child_state = state.to_child_state(
23+
child_state = state.to_child(
2424
student_subtree=state.student_parts.get(highlight_name),
2525
solution_subtree=state.solution_parts.get(highlight_name),
2626
)

pythonwhat/checks/check_logic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def override(state, solution):
141141
break
142142

143143
kwargs = state.messages[-1] if state.messages else {}
144-
child = state.to_child_state(
144+
child = state.to_child(
145145
solution_subtree=new_ast,
146146
student_subtree=state.student_tree,
147147
highlight=state.highlight,
@@ -238,7 +238,7 @@ def set_context(state, *args, **kwargs):
238238
out_sol = upd_sol
239239
out_stu = upd_stu
240240

241-
return state.to_child_state(
241+
return state.to_child(
242242
student_context=out_stu, solution_context=out_sol, highlight=state.highlight
243243
)
244244

@@ -279,7 +279,7 @@ def set_env(state, **kwargs):
279279
stu_new = stu_crnt.update(kwargs)
280280
sol_new = sol_crnt.update(kwargs)
281281

282-
return state.to_child_state(
282+
return state.to_child(
283283
student_env=stu_new, solution_env=sol_new, highlight=state.highlight
284284
)
285285

@@ -301,4 +301,4 @@ def disable_highlighting(state):
301301
Ex().check_function('round').disable_highlighting().check_args(0).has_equal_ast()
302302
Ex().check_function('round').check_args(0).disable_highlighting().has_equal_ast()
303303
"""
304-
return state.to_child_state(highlighting_disabled=True)
304+
return state.to_child(highlighting_disabled=True)

0 commit comments

Comments
 (0)