为猫测试任何协议处理
taptaptap的Python项目详细描述
name: | taptaptap |
---|---|
Author: | Lukas Prokop |
Date: | Feb-Apr 2014, Jul 2018 |
license: | BSD 3-clause |
Version: | 1.2.1 |
issues: | http://github.com/meisterluk/taptaptap/issues |
为cats*rawwr*测试任何协议处理
目录
taptaptap提供解析器、编写器和api来处理test anything协议(tap)。实现的重点是最新的tap版本13。tap源于perl社区,但它是记录testsuites运行的通用格式。提到猫只是一个双关语,用来形容猫在地板上偷偷摸摸的声音。
Compatibility
taptaptap只应该使用python 2.7(由于with语句和argparse)。 它完全支持Unicode。 它已经在2.7.15rc1上用Xubuntu 18.04(Linux4.15x86x64)进行了测试。python 3.x的一个版本作为包taptaptap3提供。
Changelog
1.2.1: | declare encoding in setup.py, README updates |
---|---|
1.2.0: | Bugfix: do not drop memo in TapBailout, shebangs: “python” → “python2”, Bugfix: initialize next_number with 1, Bugfix: issue #1 |
1.1.3: | tapmerge: support merging more than 2 TAP files, support “-” to denote stdin |
1.1.2: | TapWriter: do not reuse TapWriter instance in TapCreator |
1.1.1: | TapWriter: support data handling in TapBailout |
1.1.0: | procedural API writes to stderr not stdout, bugfix TapCreator: Fix number of testcase determination |
1.0.5: | bugfix procedural API: write version even if default version |
1.0.4: | more tests, fix output/source bug in testsuite |
1.0.3: | install_requires in setup.py |
1.0.2: | introduce requirements.txt |
1.0.1: | Unicode improvements |
1.0.0: | First stable release, packaging improvements, full testsuite |
0.8.0: | Unstable release, minimal testsuite |
Testsuite & Examples
taptaptap附带了一个testsuite,它涵盖了tap格式的许多特殊情况,并测试了所提供的api。请不要犹豫报告任何issues。
您可以使用:
./run.sh
在测试目录中。testsuite还显示了一些api使用示例,但我想在这里提供一些。如果您使用的是python repl:
from taptaptap.proc import plan, ok, not_ok, out plan(tests=10) ok('Starting the robot') not_ok('Starting the engine') not_ok('Find the object', skip='Setup required') not_ok('Terminate', skip='Setup required') out()
输出如下:
1..10 ok - Starting the robot not ok - Starting the engine not ok - Find the object # SKIP Setup required not ok - Terminate # SKIP Setup required
请注意,状态存储在模块中。如果你在REPL之外,这不是你想要的。在这种情况下,TapWriter类更方便:
import taptaptap writer = taptaptap.TapWriter() writer.plan(1, 3) writer.ok('This testcase went fine') writer.ok('And another one') writer.ok('And also the last one')
如果您喜欢python的生成器,则需要使用SimpleTapCreator:
@taptaptap.SimpleTapCreator def runTests(): yield True yield True yield False print runTests()
给我们:
1..3 ok ok not ok
或者看看更复杂的TapCreator。如果您是一个真正的专家,您可以直接使用TapDocument,这涵盖了tap的所有可能性。
Command line tools
您还可以直接从命令行调用taptaptap:
python -m taptaptap.__main__ some_tap_file_to_validate.tap
此命令将解析文件并以模块理解的方式写入文件。退出代码表示其有效性:
- 0 一切都很好。
- 1
- TAP文件缺少一些测试用例或包含失败的测试用例。
- 2 提出了一项救助计划。因此,测试环境在运行期间崩溃。
Pickling
所有对象都是可拾取的。