命令行程序的简单测试。
cmdtest的Python项目详细描述
CMDTest是测试命令行程序的一种简单方法。
from cmdtest import Program, File cat = Program('cat') @cat.test def cat_should_echo_single_file(): assert cat(File('hello')).out == 'hello' @cat.test def cat_should_combine_files(): assert cat(File('hello'), File('world')).out == 'helloworld' if __name__ == '__main__': cat.run()
安装
可从pypi获得,pip或easy_install:
$ pip install cmdtest $ easy_install cmdtest
这也将拉入证明依赖项。