PyTest 显示错误答案
PyTest shows a wrong answer
你们能告诉我我的单元测试有什么问题吗?
class Blizzard(Storm):
def __init__(self, name, wind_speed, temp):
self.temp = temp
super().__init__(name, wind_speed)
def calculate_classification(self) -> str:
if self.wind_speed >= 35:
return "Blizzard"
elif self.wind_speed >= 45 and self.temp <= -12:
return "Severe Blizzard"
return "Snow Storm"
这是我的class检查那里有什么样的暴风雪,下面你可以看到我的单元测试代码:
def test_severe_blizzard():
b1 = Blizzard("Wendy", 46, -12)
assert b1.calculate_classification() == 'Severe Blizzard'
Here is the output
风速大于 35 所以它 returns 第一个 if 语句。
你们能告诉我我的单元测试有什么问题吗?
class Blizzard(Storm):
def __init__(self, name, wind_speed, temp):
self.temp = temp
super().__init__(name, wind_speed)
def calculate_classification(self) -> str:
if self.wind_speed >= 35:
return "Blizzard"
elif self.wind_speed >= 45 and self.temp <= -12:
return "Severe Blizzard"
return "Snow Storm"
这是我的class检查那里有什么样的暴风雪,下面你可以看到我的单元测试代码:
def test_severe_blizzard():
b1 = Blizzard("Wendy", 46, -12)
assert b1.calculate_classification() == 'Severe Blizzard'
Here is the output
风速大于 35 所以它 returns 第一个 if 语句。