【问题标题】:Is there a shortcut for self.assertNotEqual() in nose?鼻子中是否有 self.assertNotEqual() 的快捷方式?
【发布时间】:2013-10-14 18:33:50
【问题描述】:

_eq 似乎等于self.assertEqual()

但是鼻子里也有self.assertNotEqual()吗?

谢谢

【问题讨论】:

  • 您使用的是哪个版本的 Python?

标签: python unit-testing nose


【解决方案1】:

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

More info here.

【讨论】:

  • 他们怎么会错过呢? :) 谢谢
  • 试试这个:from nose.tools import assert_not_equal as neq_
猜你喜欢
  • 1970-01-01
  • 2021-09-10
  • 2015-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-11
相关资源
最近更新 更多