【发布时间】:2013-10-14 18:33:50
【问题描述】:
_eq 似乎等于self.assertEqual()
但是鼻子里也有self.assertNotEqual()吗?
谢谢
【问题讨论】:
-
您使用的是哪个版本的 Python?
标签: python unit-testing nose
_eq 似乎等于self.assertEqual()
但是鼻子里也有self.assertNotEqual()吗?
谢谢
【问题讨论】:
标签: python unit-testing nose
Nose 没有与self.assertNotEqual() 等效的方法,但您可以通过nose.tools 使用所有unittest.TestCase 断言方法。它们被重命名为全小写并带有下划线。例如:
>>> from nose.tools import assert_not_equal
>>> assert_not_equal(1, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py", line 518, in assertNotEqual
raise self.failureException(msg)
AssertionError: 1 == 1
【讨论】:
from nose.tools import assert_not_equal as neq_