[英]doctest expected True, got True
doctest is hard to control. doctest很难控制。 I encontered a problem like that 我遇到了这样的问题
function 功能
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)
but got an error 但是有一个错误
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 items had failures: 1个项目有故障:
Isn't Expected matched exactly Got ? 难道不是完全匹配了吗? Thank you very much 1 of 4 in utilization.make_match Test Failed 1 failures. 非常感谢利用率4中的1。make_match 测试失败 1个失败。
您在指定期望返回值的行上有尾随空格,因此doctest
实际上将字符串"True "
与实际返回值True
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.