We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
目前的nonebug在测试时遇到和期望不相符的文本时,只会显示这样的格式:
f"Application got api call {api} with data {data} but expected {model.data}"
这经常会造成如下对人眼检查不友好的输出:
Application got api call ... with data {'foo': 1, 'bar': {'hello': 'world'}} but expected {'foo': 1, 'bar': {'hello': 'nonebug'}}
希望可以加入对 期望输出 和 实际输出 的比较,类似这样的格式:
{ "foo": 1, "bar": { - "hello": "world" ? ^ ^^^ + "hello": "nonebot" ? ^ ^^^^^ } }
这样的输出可以通过标准库difflib实现,大体类似于:
difflib
from difflib import ndiff from json import dumps print( "\n".join( ndiff( dumps(data, indent=4).splitlines(), dumps(model.data, indent=4).splitlines() ) ) )
The text was updated successfully, but these errors were encountered:
预期结果和实际内容并不一定是可json序列化的,需要使用其他方法来进行diff,可以看看pytest有无相关方法
Sorry, something went wrong.
Pytest的 assertion-rewriting 似乎符合要求 可以把现在使用的pytest.fail替换为assert
pytest.fail
assert
因为这一块matcher执行的报错会被捕获,所以并不能使用assert来改写输出
No branches or pull requests
目前的nonebug在测试时遇到和期望不相符的文本时,只会显示这样的格式:
f"Application got api call {api} with data {data} but expected {model.data}"
这经常会造成如下对人眼检查不友好的输出:
希望可以加入对 期望输出 和 实际输出 的比较,类似这样的格式:
这样的输出可以通过标准库
difflib
实现,大体类似于:The text was updated successfully, but these errors were encountered: