Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有一个库,其中包含诸如成员资格和身份(例如,,)之类的鼻子友好的assert_contains(x, y)断言assert_is(a, b)?
assert_contains(x, y)
assert_is(a, b)
Nose 提供了 stdlib 断言的独立版本:
from nose.tools import assert_in, assert_is
对于较旧的 Python,可能会使用类似于 tools.py 中的技术来包装 unittest2 版本。
Stdlib unittest提供assertIn并且assertIs可以通过鼻子运行。你在寻找其他的东西吗?顺便说一句,这些方法仅从 python 2.7 开始可用,如果你想要它们用于旧版本的 python,它可以从unittest2包中获得
assertIn
assertIs