我将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
,以便在pycharm中正确打印pytest
结果?