递归地在包中查找测试

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获得许可。如果是这样请告诉我 给你带来了麻烦

变更日志

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何使用java向dropup html/css添加项目   如何从java中的向量向量打印   Java Maven库项目模板   java使用atmosphere api还是直接使用grizzly?   java JComponent仅部分显示   如何将动态值传递给自定义注释,以从Java数据进行映射。性质   java破解已实现方法的返回类型的最佳方法?   java Netbeans在JFrame Gui布局中覆盖图像   spring java仅向登录用户显示注销按钮   java如何对com进行身份验证。谷歌。云bigquery。带有服务帐户的BigQuery`   java禁止空字符串参数和抛出RuntimeException以阻止方法继续的利弊   java分析项目中的所有JAR以获取版本和许可证信息   Java,数据库为什么要分配一个新对象,而我们可以直接将它放入数据库