Question: BlockPy: 4 ) Scariest Place In the code below, you need to write unit tests to evaluate a function named scariest _ place. scariest _

BlockPy: 4) Scariest Place
In the code below, you need to write unit tests to evaluate a function named scariest_place.
scariest_place(places: list[Place])-> str: Consumes a list of Place and produces the name of the Place that has the most monsters. The list of Place might have a Place with the name "exit" - when this place is encountered, the rest of that list AFTER the Exit place should be ignored. If more than one Place has the most monsters, return the one that is later in the list. If there are no places available, then return the string "none" instead.
Do not modify the definition of Place.
Remember: You should not implement the scariest_place function yourself! Write the tests!*
Feedback with no code:
Feedback:
Failed Instructor Test
I ran your test cases against some of my own implementations of scariest_place.
I had 1 programs I expected to pass, and 9 programs I expected to fail.
Your tests did not pass 1 of my genuine programs.
Your tests did not catch 9 of my impostor programs.
Here are the names for the genuine programs that incorrectly failed on your test cases:
Correct Program #1
Here are the names for the impostor programs that incorrectly passed your tests:
Failed Wrong Program #1. Hint: Returns last Failed Wrong Program
#2. Hint: Grabbed last exit Failed Wrong Program
#3. Hint: Not actually taking Failed Wrong Program
#4. Hint: Not taking the exit Failed Wrong Program
#5. Hint: Filtering instead of Taking Failed Wrong Program
#6. Hint: No places. Failed Wrong Program
#7. Hint: Min vs Max Failed Wrong Program
#8. Hint: Breaking ties Failed Wrong Program
#9. Hint: This wrong program expects an exit (but exit is optional)
Code given:
from bakery import assert_equal
from dataclasses import dataclass
# Do not modify this definition
@dataclass
class Place:
name: str
monsters: list[str]
# NOTE
# Assume that the function scariest_place is already defined!
# Do NOT write scariest_place yourself!
# ONLY write the assert_equal statements below!
assert_equal(scariest_place(___),___)
assert_equal(scariest_place(___),___)
# ... Write some more too!
My code:
assert_equal(scariest_place([
Place("Dungeon",["monster1"]),
Place("Forest",["monster2", "monster3"]),
Place("Castle",["monster4"])
]), "Forest")
assert_equal(scariest_place([
Place("Dungeon",["monster1", "monster2"]),
Place("Forest",["monster3", "monster4"]),
Place("exit",[])
]), "Forest")
assert_equal(scariest_place([
Place("Dungeon",[]),
Place("Forest",[]),
Place("Castle",[])
]), "Castle")
assert_equal(scariest_place([
Place("Dungeon",["monster1"]),
Place("exit",[]),
Place("Forest",["monster2", "monster3"])
]), "Dungeon")
assert_equal(scariest_place([]), "none")
assert_equal(scariest_place([
Place("Dungeon",["monster"]),
Place("Forest",["monster1", "monster2", "monster3"]),
Place("Castle",["monster4", "monster5"])
]), "Forest")
assert_equal(scariest_place([
Place("Dungeon",["monster1", "monster2"]),
Place("Forest",["monster3", "monster4"]),
Place("Castle",["monster5", "monster6"])
]), "Castle")
assert_equal(scariest_place([
Place("Dungeon",["monster1"]),
Place("Forest",["monster2", "monster3"]),
Place("Castle",["monster4", "monster5"])
]), "Castle")
assert_equal(scariest_place([
Place("Dungeon",["monster1"]),
Place("Forest",["monster2"]),
Place("exit",[]),
Place("Castle",["monster3", "monster4"])
]), "Forest")
assert_equal(scariest_place([
Place("Dungeon",["monster1"]),
Place("exit",[]),
Place("Castle",["monster2", "monster3"]),
Place("exit",[]),
Place("Forest",["monster4", "monster5"])
]), "Dungeon")
assert_equal(scariest_place([
Place("Dungeon",["monster1"]),
Place("Forest",["monster2"]),
Place("Castle",["monster3", "monster4"]),
Place("exit",[])
]), "Castle")
assert_equal(scariest_place([Place("exit",[])]), "none")
assert_equal(scariest_place([
Place("Dungeon",["monster1"]),
Place("exit",[]),
Place("Castle",["monster2", "monster3", "monster4"])
]), "Dungeon")
Does not work, keeps saying:
Feedback:
Failed Instructor Test
I ran your test cases against some of my own implementations of scariest_place.
I had 1 programs I expected to pass, and 9 programs I expected to fail.
Your tests did not pass 1 of my genuine programs.
At least one of your tests correctly failed for all of my impostor programs.
Here are the names for the genuine programs that incorrectly failed on your test cases:
Correct Program #1
I been stuck for 30 minutes and can't figure out what I am missing, can you please review my unit test and and help me.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!