简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM