Skip to content

Commit 2511b67

Browse files
committed
Set correct partial names
1 parent 4c4c93f commit 2511b67

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

pythonwhat/checks/check_wrappers.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -703,27 +703,36 @@ def rename_function(func, name):
703703
func.__name__ = func.__qualname__ = name
704704

705705

706-
scts["has_equal_name"] = state_partial(
707-
has_equal_part,
708-
"name",
709-
msg="Make sure to use the correct {{name}}, was expecting {{sol_part[name]}}, instead got {{stu_part[name]}}.",
706+
def add_partial_sct(func, name):
707+
rename_function(func, name)
708+
scts[name] = func
709+
710+
711+
add_partial_sct(
712+
state_partial(
713+
has_equal_part,
714+
"name",
715+
msg="Make sure to use the correct {{name}}, was expecting {{sol_part[name]}}, instead got {{stu_part[name]}}.",
716+
),
717+
"has_equal_name",
710718
)
711-
scts["is_default"] = state_partial(
712-
has_equal_part,
719+
add_partial_sct(
720+
state_partial(
721+
has_equal_part,
722+
"is_default",
723+
msg="Make sure it {{ 'has' if sol_part.is_default else 'does not have'}} a default argument.",
724+
),
713725
"is_default",
714-
msg="Make sure it {{ 'has' if sol_part.is_default else 'does not have'}} a default argument.",
715726
)
716727

717728
# include rest of wrappers
718729
for k, v in __PART_WRAPPERS__.items():
719730
check_fun = state_partial(check_part, k, v)
720-
rename_function(check_fun, "check_" + k)
721-
scts[check_fun.__name__] = check_fun
731+
add_partial_sct(check_fun, "check_" + k)
722732

723733
for k, v in __PART_INDEX_WRAPPERS__.items():
724734
check_fun = state_partial(check_part_index, k, part_msg=v)
725-
rename_function(check_fun, "check_" + k)
726-
scts[check_fun.__name__] = check_fun
735+
add_partial_sct(check_fun, "check_" + k)
727736

728737
for k, v in __NODE_WRAPPERS__.items():
729738
check_fun = state_partial(check_node, k + "s", typestr=v["typestr"])
@@ -732,8 +741,7 @@ def rename_function(func, name):
732741
missing_msg="missing_msg: If specified, this overrides the automatically generated feedback message in case the construct could not be found.",
733742
expand_msg="expand_msg: If specified, this overrides the automatically generated feedback message that is prepended to feedback messages that are thrown further in the SCT chain.",
734743
)
735-
rename_function(check_fun, "check_" + k)
736-
scts[check_fun.__name__] = check_fun
744+
add_partial_sct(check_fun, "check_" + k)
737745

738746
for k in [
739747
"set_context",

pythonwhat/checks/has_funcs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ def has_expr(
371371

372372

373373
has_equal_value = partial(has_expr, test="value")
374+
has_equal_value.__name__ = "has_equal_value"
374375
has_equal_value.__doc__ = (
375376
"""Run targeted student and solution code, and compare returned value.
376377
@@ -403,6 +404,7 @@ def has_expr(
403404

404405

405406
has_equal_output = partial(has_expr, test="output")
407+
has_equal_output.__name__ = "has_equal_output"
406408
has_equal_output.__doc__ = """Run targeted student and solution code, and compare output.
407409
408410
When called on an SCT chain, ``has_equal_output()`` will execute the student and solution
@@ -412,6 +414,7 @@ def has_expr(
412414
)
413415

414416
has_equal_error = partial(has_expr, test="error")
417+
has_equal_error.__name__ = "has_equal_error"
415418
has_equal_error.__doc__ = """Run targeted student and solution code, and compare generated errors.
416419
417420
When called on an SCT chain, ``has_equal_error()`` will execute the student and solution

0 commit comments

Comments
 (0)