From 6949c963cc365bbef8a68f47b6e637bfb37a7d77 Mon Sep 17 00:00:00 2001 From: Dario <105294544+Dario-DC@users.noreply.github.com> Date: Fri, 5 Dec 2025 20:36:11 +0100 Subject: [PATCH] fix(curriculum): update email simulator tests (#63803) --- .../685cdfd1932d8ac6ad986813.md | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/curriculum/challenges/english/blocks/workshop-email-simulator/685cdfd1932d8ac6ad986813.md b/curriculum/challenges/english/blocks/workshop-email-simulator/685cdfd1932d8ac6ad986813.md index 9fe7a1376e4..c62fc610f77 100644 --- a/curriculum/challenges/english/blocks/workshop-email-simulator/685cdfd1932d8ac6ad986813.md +++ b/curriculum/challenges/english/blocks/workshop-email-simulator/685cdfd1932d8ac6ad986813.md @@ -15,24 +15,14 @@ Here is an example: ```py x = 10 -y = 'Even' if x % 2 == 0 else 'Odd' # y will be even +y = 'Even' if x % 2 == 0 else 'Odd' # y will be Even ``` Within the method, before, use conditional expression to assign the string `Read` to a variable `status` if the email is read and `Unread` if it is not. # --hints-- -The `__str__` method should create a `status` variable that uses a conditional expression. - -```js -({ - test: () => { - assert(runPython(`_Node(_code).find_class("Email").find_function("__str__").has_stmt("status = 'Read' if self.read else 'Unread'")`)); - } -}) -``` - -The `__str__` method should return the email information with the status included. +You should have a `status` variable within the `__str__` method. ```js ({ @@ -42,6 +32,37 @@ The `__str__` method should return the email information with the status include }) ``` +You should assign a conditional expression to the `status` variable. + +```js +({ + test: () => { + runPython(` + import ast + assert isinstance(_Node(_code).find_class("Email").find_function("__str__").find_variable("status").tree.value, ast.IfExp)`); + } +}) +``` + +Your conditional expression should evaluate to the string `Read` if the email is read and `Unread` if it is not. + +```js +({ + test: () => { + runPython(` + if_exps = [ + "'Read' if self.read else 'Unread'", + "'Read' if self.read == True else 'Unread'", + "'Unread' if not self.read else 'Read'", + "'Unread' if self.read == False else 'Read'" + ] + foo = _Node(_code).find_class("Email").find_function("__str__") + assert any(foo.has_stmt(f"status = {if_exp}") for if_exp in if_exps) + `); + } +}) +``` + # --seed-- ## --seed-contents--