递归地在包中查找测试
chaoflow.testing.crawler的Python项目详细描述
导言
chaoflow.testing.crawler的目的是在包中查找测试,并 在显式定义的文件中运行它们和测试。
测试可在以下文件中找到:
- 作为包(子包)一部分的所有.py文件,即 您可以使用import 导入
- 所有具有相应.py文件的.txt文件
- 您可以指定的所有文件
找到的所有测试都可以单独运行,例如使用zc.recipe.testrunner
使用测试爬网程序
要对包使用测试爬网程序,只需复制一个 文件并声明对setup.py中的chaoflow.testing.crawler的依赖关系。
将此文件放入包根目录,并将文件列表调整为显式 指定未找到的测试文件,tests.py:
# chaoflow.testing.crawler.tests.py # # You can simply copy this file to your package and adjust it to your needs from chaoflow.testing.crawler import create_test_suite # File to test, relative to the package root # all .py files are found # all .txt files with corresponding .py file are found files = [ 'README.txt' ] # We assume that this modules is in the root of your package pkgname = __name__[:-6] test_suite = create_test_suite(pkgname, files)
在setup.py中声明依赖关系:
setup(... extras_require={ 'test': [ 'interlude', 'chaoflow.testing.ipython', 'chaoflow.testing.crawler', ], }, )
如果有插曲可用,interlude.interact将作为 interact在您的测试环境中
如果chaoflow.testing.ipython可用,ipshell将作为 ipshell在您的测试环境中。
使用chaoflow.testing.crawler和zc.recipe.testrunner的buildout.cfg示例:
[buildout] develop = . parts = test py [test] recipe = zc.recipe.testrunner eggs = chaoflow.testing.crawler [test] [py] recipe = zc.recipe.egg interpreter = py eggs = ${test:eggs}
构建之后,可以使用./bin/test运行测试。 运行./bin/test --list-tests以获取所有已注册测试的列表,并查看 ./bin/test --help了解更多信息
许可证
chaoflow.testing.crawler根据lgplv3获得许可。如果是这样请告诉我 给你带来了麻烦