python - PyTest shows a wrong answer
问题描述
Can you guys tell me what am I doing wrong with my unit testing?
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"
Here is my class to check what kind of blizzard is there and below you can see my unit test code:
def test_severe_blizzard():
b1 = Blizzard("Wendy", 46, -12)
assert b1.calculate_classification() == 'Severe Blizzard'
解决方案
The wind speed is greater than 35 so it returns the first if statement.
推荐阅读
- svg - SVG 在 IE 11 中重复两次,在 Chrome 中运行良好
- ruby-on-rails-5 - 是否可以删除 ActiveRecord 关系的“默认”WHERE 规则?
- mysql - 来自不同行(具有相同日期)数据的日期表的 GROUP 结果
- javascript - Express Body-parser 文件上传大小限制不起作用
- java - 如何返回程序的开头 - java
- hadoop - 从包含 Map(retweet -> 0,loc -> none) 形式的数据的文件创建一个配置单元表
- c++ - fopen("filename", "wb") 返回 null
- python - 成对余弦相似度 Python
- python - JSON保存到文件获取方法
- oracle - 无法从远程客户端插入 oracle bfile 数据类型列