[英]Is there a way to use the unittest module to assert if (x) is in a list?
I'm trying to write some test cases, and I ran into a problem.我正在尝试编写一些测试用例,但遇到了问题。 I would like to be able to assert something like this:
我希望能够断言这样的事情:
x in [x, y]
Is there a way to do this with Python's unittest
module?有没有办法用 Python 的
unittest
模块做到这一点?
I've found the answer thanks to a comment on this question.由于对此问题的评论,我找到了答案。 (Thanks, Steven!)
(谢谢,史蒂文!)
The module has an assertIn
function that I didn't catch before.该模块有一个我以前没有发现的
assertIn
function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.