以下测试:
def test_something():
assert "ddd" == "pepe"
当pytest出现以下错误时运行:
^{pr2}$但是,如果我们将assert方法移动到另一个文件assertion.py
:
class CustomerAssertor(object):
def __init__(self,name):
self.name =name
def assert_name(self,expected):
assert self.name ==expected
我们将测试改为:
from sql_gen.test.utils.assertion_util import CustomerAssertor
def test_something():
CustomerAssertor("ddd").assert_name("pepe")
现在我得到以下错误:
self = <assertions.CustomerAssertor object at 0x7fbcc3d31588>, expected = 'pepe'
def assert_name(self,expected):
> assert self.name ==expected
E AssertionError
这条消息并没有告诉您名称的值是什么,这是为什么?在
从docs:
相关问题 更多 >
编程相关推荐