测试驱动开发:nose、py.test、Fakes、Mocks与文档驱动开发
1. nose测试工具
1.1 安装
nose是一个具有强大发现功能的测试运行器,可使用easy_install进行安装:
$ easy_install nose安装过程中会搜索相关资源并处理依赖:
Searching for nose Reading http://pypi.python.org/simple/nose/ Reading http://somethingaboutorange.com/mrl/projects/nose/ ... Processing dependencies for nose Finished processing dependencies for nose1.2 测试运行
安装完成后,会出现nosetests命令,可直接使用该命令运行测试。例如:
$ nosetests -v test_average (test_utils.MyTests) ... ok test_another_test (test_utils.MyTests2) ... ok builds the test suite. ... ok ---------------------------------