功能
from collections import namedtuple
Match = namedtuple('Match', ['token_string', 'normalised_token',
'brand_name', 'brand_id',
'score'])
def make_match(tokens, normalised, brand, score):
"""
Examples:
>>> make_match('Jack Jones','JackJones',('Jack Jones','X023'),0.6)==Match('Jack Jones','JackJones','Jack Jones','X023',0.6)
True
>>> make_match('Jack Jones','JackJones',('Jack Jones','X023'),0.6)==('Jack Jones','JackJones','Jack Jones','X023',0.6)
True
>>> match=make_match('Jack Jones','JackJones',('Jack Jones','X023'),0.6)
>>> match.token_string=='Jack Jones'
True
"""
return Match(token_string=tokens,
normalised_token=normalised,
brand_name=brand[0],
brand_id=brand[1],
score=score)
但收到错误
Failed example:
make_match('Jack Jones','JackJones',('Jack Jones','X023'),0.6)==Match('Jack Jones','JackJones','Jack Jones','X023',0.6)
Expected:
True
Got:
True
1项失败:
预期不符合匹配吗? 非常感谢你 util.make_match中的1/4 测试失败 1次失败。
答案 0 :(得分:5)
您在行上指定了预期返回值的尾随空格,因此doctest
实际上是将字符串"True "
与实际返回值True
进行比较。