跳转到主要内容

递归查找您的包中的测试

项目描述

简介

chaoflow.testing.crawler的目的是查找您的包中的测试,并运行与您显式定义的文件中的测试。

测试将在以下文件中找到

  • 您的包(子包)中所有.py文件,即您可以导入的文件

  • 所有具有相应.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可用,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 许可。如果这给您带来问题,请告知我。

变更日志

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源代码发行版

chaoflow.testing.crawler-0.5.zip (37.2 kB 查看哈希值)

上传时间 源代码

由以下支持