递归地在包中查找测试

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第三方库


热门话题
在收到远程通知时对iBeacon进行java扫描   尝试在Java中实现MD5哈希的算法   java getLastLocation最近有多久了?   java线程创建侦听器   swing Java JComboBox接受ArrayList,但不显示ArrayList的项   构建服务器上的java XML验证速度较慢   Tomcat无法识别java中的更改(Intellij配置)   java 5中引入泛型的原因   java意图。Android中的额外_流   for循环Java直接遍历数组而不是数组变量   java内部类中的两个声明构造函数   java试图使用子文本字段在JPanel上设置边框   java如何允许在Android WebView中进行条带签出?   在Java中,如何将数字从一个类转移到另一个类?   从任务栏关闭浏览器时的java会话   java有没有一种自动化的方法来确保代码的所有部分都经过单元测试?   2DArrays Java编码查找数组