python 的 fail() 没有暴露在鼻子里?

fail() not exposed in nose for python?

我正在使用 nose 运行 我的测试,我有一个不扩展 unittest.TestCase.

的测试方法

我想根据条件使测试失败,但 nose 似乎没有 fail() 方法?

实际上,我不太确定 assert_equals 是如何工作的,要么它没有在工具模块中定义,但它以某种方式工作。

您可以使用内置的 assert 语句使测试失败,在幕后看起来有点像这样:

   assert condition, "This condition failed"

   # which is the same as:
   if not condition: 
       raise AssertionError