在 Nose 测试框架 Python Qualis 中获取 AssertionError

问题描述

        for exp in expected:

>           assert bool(re.search(exp,code))

E           AssertionError

.test/test_nose.py:64: AssertionError

这是我得到的错误,这是我定义断言的地方:

def test_circlearea_with_random_numeric_radius(self):
    # Define a circle 'c1' with radius 2.5,and check if 
    # its area is 19.63.
    c1 = Circle(2.5)
assert c1.area() == 19.63

有人知道为什么会这样吗?

解决方法

现在才看到这个帖子..

请按如下方式使用,并使用'fromnose.tools import assert_raises,eq_'

def test_circlearea_with_random_numeric_radius(self):
    # Define a circle 'c1' with radius 2.5,and check if 
    # its area is 19.63.
    c1 = Circle(2.5)
    eq_(c1.area(),19.63) #<--as the test_nose.py program is looking for eq_() 

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...