Skip to content

Commit 0462d4f

Browse files
committed
resolve weird special message in fix_make_board
1 parent 34467a2 commit 0462d4f

File tree

5 files changed

+30
-8
lines changed

5 files changed

+30
-8
lines changed

core/chapters/c11_tic_tac_toe_project.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,18 +1768,18 @@ def make_board(size):
17681768
def generate_inputs(cls):
17691769
return dict(size=randint(4, 12))
17701770

1771-
# TODO
1772-
class special_messages_:
1771+
class special_messages:
17731772
class not_separate:
1774-
text = "The sublists in the result are not all separate objects."
1773+
text = "However, the sublists in the result are not all separate objects."
17751774
program = "pass\ndef make_board(size): return [[' '] * size] * size"
1775+
expected_exact_match = False
17761776

17771777
@classmethod
17781778
def check_result(cls, func, inputs, expected_result):
17791779
test_result, func_result = check_result(func, inputs, expected_result)
17801780
if test_result["passed"] and len(func_result) != len(set(map(id, func_result))):
17811781
test_result["passed"] = False
1782-
test_result["message"] += "\n\n" + cls.special_messages_.not_separate.text
1782+
test_result["message"] += "\n\n" + cls.special_messages.not_separate.text
17831783
return test_result
17841784

17851785
final_text = """

tests/golden_files/en/test_transcript.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6665,6 +6665,19 @@
66656665
},
66666666
"step": "naive_make_board"
66676667
},
6668+
{
6669+
"page": "Making the Board",
6670+
"program": [
6671+
"pass",
6672+
"def make_board(size): return [[' '] * size] * size"
6673+
],
6674+
"response": {
6675+
"message": "<p>Given these values:</p>\n<pre><code class=\"codehilite\"><span><span class=\"n\">size</span> <span class=\"o\">=</span> <span class=\"mi\">2</span>\n</span></code></pre>\n<p>your code outputs:</p>\n<pre><code class=\"codehilite\"><span><span class=\"p\">[[</span><span class=\"s1\">' '</span><span class=\"p\">,</span> <span class=\"s1\">' '</span><span class=\"p\">],</span> <span class=\"p\">[</span><span class=\"s1\">' '</span><span class=\"p\">,</span> <span class=\"s1\">' '</span><span class=\"p\">]]</span>\n</span></code></pre>\n<p>which is correct!</p>\n<p>However, the sublists in the result are not all separate objects.</p>",
6676+
"passed": false,
6677+
"result": []
6678+
},
6679+
"step": "fix_make_board"
6680+
},
66686681
{
66696682
"get_solution": "program",
66706683
"page": "Making the Board",

tests/test_steps.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,13 @@ def normalise_response(response, is_message, substep):
102102
assert not message_sections
103103
else:
104104
section = message_sections[0]
105-
assert section == dict(
106-
type="messages",
107-
messages=[highlighted_markdown(substep.text)],
108-
)
105+
assert set(section.keys()) == {"type", "messages"}
106+
assert section["type"] == "messages"
107+
assert len(section["messages"]) == 1
108+
message = section["messages"][0]
109+
expected = highlighted_markdown(substep.text)
110+
if getattr(substep, "expected_exact_match", True):
111+
assert expected == message
112+
else:
113+
assert expected in message
109114
response["message"] = only(section["messages"])

translations/english.po

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27460,6 +27460,10 @@ msgstr "There are a few ways to copy a list in Python with a tiny bit of code."
2746027460
msgid "pages.MakingTheBoard.steps.fix_make_board.hints.8.text"
2746127461
msgstr "Making a new row each time can be done by just rearranging the code."
2746227462

27463+
#. https://futurecoder.io/course/#MakingTheBoard
27464+
msgid "pages.MakingTheBoard.steps.fix_make_board.special_messages.not_separate.text"
27465+
msgstr "However, the sublists in the result are not all separate objects."
27466+
2746327467
#. https://futurecoder.io/course/#MakingTheBoard
2746427468
#.
2746527469
#. # __code0__:
159 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)