pytest输出结果在pycharm中乱码

格热斯

我将pytest与pycharm一起使用,但是当我运行测试时,在pycharm控制台中我得到了测试和结果乱码,这是示例输出:

============================= test session starts ==============================
platform linux -- Python 3.6.6, pytest-4.0.1, ....
cachedir: .pytest_cache
rootdir: ....
collecting ... collected 14 items

tests/test_ops.py::test_layer 
tests/test_ops.py::test_layer_with_input_shape 
tests/test_ops.py::test_layer_with_batch_input 
tests/test_ops.py::test_layer_with_batch_size_and_input_shape 
tests/test_ops.py::test_rshift_input_layer 
tests/test_ops.py::test_rshift_input_list 
tests/test_ops.py::test_rshift_two_layers 
tests/test_ops.py::test_rshift_input_and_two_layers 
tests/test_ops.py::test_rshift_input_and_deferred_layer 
tests/test_ops.py::test_rshift_input_list_and_deferred_layer 
tests/test_ops.py::test_rshift_deferred_layer_to_layer 
tests/test_ops.py::test_rshift_layer_to_deferred_layer 
tests/test_ops.py::test_rshift_layer_to_int 
tests/test_ops.py::test_rshift_layer_to_int_with_inputs 

========================== 14 passed in 1.27 seconds ===========================PASSED                                     [  7%]PASSED                    [ 14%]Tensor_rshift_layer
PASSED                    [ 21%]Tensor_rshift_layer
PASSED     [ 28%]Tensor_rshift_layer
PASSED                        [ 35%]Tensor_rshift_layer
PASSED                         [ 42%]list_rshift_layer
PASSED                         [ 50%]layer_rshift_layer
PASSED               [ 57%]Tensor_rshift_layer
PASSED           [ 64%]layer_rshift_layer
Tensor_rshift_layer
PASSED      [ 71%]layer_rshift_layer
list_rshift_layer
PASSED            [ 78%]layer_rshift_layer
layer_rshift_layer
PASSED            [ 85%]layer_rshift_layer
layer_rshift_layer
PASSED                       [ 92%]layer_rshift_int
layer_rshift_layer
PASSED           [100%]layer_rshift_int
layer_rshift_layer
Tensor_rshift_layer

这不是很漂亮,并且结果在测试功能报告之后打印。

这是pytest从终端运行时的外观

$ pytest -v -p no:warnings --color=yes

================================ test session starts ================================
platform linux -- Python 3.6.6, pytest-4.0.1, ...
cachedir: .pytest_cache
rootdir: ...
collected 14 items                                                                  

tests/test_ops.py::test_layer PASSED                                          [  7%]
tests/test_ops.py::test_layer_with_input_shape PASSED                         [ 14%]
tests/test_ops.py::test_layer_with_batch_input PASSED                         [ 21%]
tests/test_ops.py::test_layer_with_batch_size_and_input_shape PASSED          [ 28%]
tests/test_ops.py::test_rshift_input_layer PASSED                             [ 35%]
tests/test_ops.py::test_rshift_input_list PASSED                              [ 42%]
tests/test_ops.py::test_rshift_two_layers PASSED                              [ 50%]
tests/test_ops.py::test_rshift_input_and_two_layers PASSED                    [ 57%]
tests/test_ops.py::test_rshift_input_and_deferred_layer PASSED                [ 64%]
tests/test_ops.py::test_rshift_input_list_and_deferred_layer PASSED           [ 71%]
tests/test_ops.py::test_rshift_deferred_layer_to_layer PASSED                 [ 78%]
tests/test_ops.py::test_rshift_layer_to_deferred_layer PASSED                 [ 85%]
tests/test_ops.py::test_rshift_layer_to_int PASSED                            [ 92%]
tests/test_ops.py::test_rshift_layer_to_int_with_inputs PASSED                [100%]

============================= 14 passed in 1.25 seconds =============================

有没有一种方法可以配置pycharm的控制台,或者pytest使其pytest在pycharm中正确打印结果?

格热斯

当我取消选中“ Track running test”时,输出看起来更好,如下图:在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TOP 榜单

热门标签

归档