问题描述
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_()