python - 为什么我的 pycharm 调试控制台输出未显示与 pytest 的正确差异
问题描述
我正在通过 Pycharm 在 Windows 上编写 python 3.7。我一直使用单独的终端窗口来运行我的测试,但我目前正在尝试原生 pycharm 测试运行器。我遇到了一个真正困扰我的问题。
如果我有这个测试:
def test__output_test():
assert ['123\n', '456\n', '789\n'] == ['123\n', '455\n', '789\n']
当我通过命令行直接在 powershell 中运行它时python -m pytest -vv <path>
,我得到了这个可爱的输出:
def test__output_test():
> assert ['123\n', '456\n', '789\n'] == ['123\n', '455\n', '789\n']
E AssertionError: assert ['123\n', '456\n', '789\n'] == ['123\n', '455\n', '789\n']
E At index 1 diff: '456\n' != '455\n'
E Full diff:
E - ['123\n', '455\n', '789\n']
E ? ^
E + ['123\n', '456\n', '789\n']
E ? ^
但是当我通过 pycharm 的 pytest 测试运行器运行相同的测试时(-vv 在“附加参数”中设置),输出似乎截断了实际的差异显示:
def test__output_test():
> assert ['123\n', '456\n', '789\n'] == ['123\n', '455\n', '789\n']
E AssertionError: assert ['123\n', '456\n', '789\n'] == ['123\n', '455\n', '789\n']
..\tests\unit\test__output.py:4: AssertionError
似乎尝试在测试结果输出上方进行差异,但与我在 powershell 中得到的相比,这很糟糕:
FAILED [100%]
unit\test__output.py:2 (test__output_test)
['123
', '456
', '789
'] != ['123
', '455
', '789
']
<Click to see difference>
如果我单击“查看差异”链接弹出的差异查看器是“好的”,因为它会突出显示修改后的单词/符号,但它仍然会弄乱引用的换行符
我试图将我的 pycharm 终端设置为 powershell,但这并没有改变调试控制台的输出。我想知道是否需要设置一些额外的参数或设置来查看我的首选差异?
解决方案
推荐阅读
- android - 如何显示名称
- java - hashset和hashmap的多重关系
- java - 解析 ASN1 编码的整数
- reactjs - 这种方法是否是避免 .map 的正确方法不是 ReactJS 中的函数
- javascript - 反应无状态子组件不会更新父组件中的状态更改
- excel - 每个新行都应创建一个具有相同格式的独立 word 文档
- javascript - 想用php查看json文件数据
- android - 错误:任务':react-native-fbads:processDebugResources'的执行失败。> com.android.ide.common.process.ProcessException:无法执行 aapt
- ios - 以编程方式设置约束不适用于我的表格视图
- ios - 上面有真实世界对象的 ARKit 平面