单元测试彩色输出 [英] unittest colored output

查看:39
本文介绍了单元测试彩色输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 unittest(实际上是 unittest2)和 Python Mock 用于模拟对象,nose 用于运行所有测试单程.

I use unittest (actually unittest2) for Python testing, together with Python Mock for mocking objects and nose to run all tests in a single pass.

我怀念能够通过绿色/红色条一眼看出什么是有效的,什么是错误的.有没有办法从单元测试中获得彩色输出?

I miss being able to tell what is working and what's wrong at a glance from the green/red bars. Is there a way to get colored output from unittest?

(此时更改测试套件不是一个选项,我实际上喜欢 unittest)

推荐答案

在 python 2.x 中你可以试试 pyrg.不过在 Python 3 中不起作用.

In python 2.x you could try pyrg. Does not work in Python 3 though.

这篇关于单元测试彩色输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆