回答
如果您已经使用了部署光纤,就可以使用这个片段来自@codeinthehole's blog post:
from fabric.colors import _wrap_with
green_bg = _wrap_with('42')
red_bg = _wrap_with('41')
# Set the list of apps to test
env.test_apps = "app1 app2"
def test():
with settings(warn_only=True):
result = local('./manage.py test %(test_apps)s --settings=settings_test -v 2 --failfast' % env, capture=False)
if result.failed:
print red_bg("Some tests failed")
else:
print green_bg("All tests passed - have a banana!")
它不colorise个别测试输出,但它确实给你直接的红/绿满意...
看看Print in terminal with colors using Python?。您应该可以从那里修改或推出自己的颜色。
如果你不使用布,你可能会喜欢redgreenunittest
。基本上,你只要把它放在适当的位置在您的项目(在虚拟环境中可能),然后引用它如您在设置您的TEST_RUNNER
这样的:
TEST_RUNNER="redgreenunittest.django.simple.RedGreenTestSuiteRunner"
如果你只使用Django的测试帮手代码(主要是django.test.TestCase),那么应该这样做。否则,你可能需要直接引用redgreenunittest
像这样:
import redgreenunittest as unittest
然后你只需运行测试。他们会有颜色。像魔术一样。
我知道这是一个老问题,但django-rainbowtests旨在做到这一点。失败和错误是红色的,成功是绿色的,它会在更大的堆栈跟踪中突出显示项目的代码。
redgreenunittests是最简单的解决方案,它的伟大工程与Python 3.x的
安装它
pip install redgreenunittest
在下一行添加到settings.py
TEST_RUNNER = "redgreenunittest.django.runner.RedGreenDiscoverRunner"
别忘了t Ø享受:)
./manage test
其实这个软件包是redgreenunittest(即使git repo有一个“s”),所以你需要运行'pip install redgreenunittest '。 –
- 1. 着色golang测试运行输出
- 2. Django在runserver.py中着色输出
- 3. 当使用“堆栈测试”时,我的hspec测试输出没有着色
- 4. 着色ifort输出
- 5. 着色PyLint输出?
- 6. 着色/高亮导轨3'耙测试'输出
- 7. Java:Windows中的着色输出
- 8. 测试着色器的兼容性
- 9. 测试输出
- 10. dcraw的输出有棋盘着色
- 11. NetBeans8不着色GlassFish的输出日志
- 12. VS2012 D3D调试 - 查看所有着色器输出
- 13. 从Cucumber输出“管道”输出时的文字着色
- 14. rspec输出测试
- 15. 测试台输出
- 16. 坐标输出CG顶点着色器
- 17. 如何为NAnt输出着色?
- 18. Unity5 - 着色器流输出阶段
- 19. HLSL几何着色器空输出
- 20. 在eclipse中着色slf4j/log4j输出
- 21. 功能Git别名输出着色
- 22. 片段着色:输出变量
- 23. 如何着色git-status输出?
- 24. 片段着色器输出值
- 25. GLSL片段着色器结构输出
- 26. 在窗口着色控制台输出
- 27. C++着色控制台输出
- 28. 着色器输出不匹配
- 29. 测试输入\输出
- 30. 测试grep的输出
还有就是一个包,这是否很容易被称为彩色光(HTTP://pypi.python。org/pypi/colorama) –