面向人类的Python测试
项目描述
pspec
=====
[](https://travis-ci.org/bfirsh/pspec)
面向人类的Python测试,使用[Attest](http://packages.python.org/Attest/)构建。
测试不仅仅是让计算机检查代码是否运行正确。它们也可以由人类用来了解代码的功能。
pspec测试被设计成由人类解析。它们看起来有点像这样
```python
from pspec import describe, assert_raises
import random
with describe('random')
with describe('shuffle')
def it_does_not_lose_any_elements()
seq = range(10)
random.shuffle(seq)
seq.sort()
assert seq == range(10)
def it_raises_an_exception_for_an_immutable_sequence()
with assert_raises(TypeError)
random.shuffle((1, 2, 3))
with describe('choice')
def it_picks_an_element_that_is_in_the_sequence()
seq = range(10)
assert random.choice(seq) in seq
```
(与[内置unittest模块的类似示例](https://docs.pythonlang.cn/library/unittest.html#basic-example)进行比较。)
它们使用`pspec`命令运行
pip install -r requirements.txt
pspec spec
目标
-----
**注意**:pspec还处于初级阶段。不要期望它现在就有用。
这是我想要它做到的事情
- 美观的测试报告,带有彩色字符串差异。(类似于[Mocha的](http://visionmedia.github.com/mocha/#string diffs))
- 上下文、before/after钩子等。
它将简单、Pythonic,并使用最小魔法。
=====
[](https://travis-ci.org/bfirsh/pspec)
面向人类的Python测试,使用[Attest](http://packages.python.org/Attest/)构建。
测试不仅仅是让计算机检查代码是否运行正确。它们也可以由人类用来了解代码的功能。
pspec测试被设计成由人类解析。它们看起来有点像这样
```python
from pspec import describe, assert_raises
import random
with describe('random')
with describe('shuffle')
def it_does_not_lose_any_elements()
seq = range(10)
random.shuffle(seq)
seq.sort()
assert seq == range(10)
def it_raises_an_exception_for_an_immutable_sequence()
with assert_raises(TypeError)
random.shuffle((1, 2, 3))
with describe('choice')
def it_picks_an_element_that_is_in_the_sequence()
seq = range(10)
assert random.choice(seq) in seq
```
(与[内置unittest模块的类似示例](https://docs.pythonlang.cn/library/unittest.html#basic-example)进行比较。)
它们使用`pspec`命令运行
目标
-----
**注意**:pspec还处于初级阶段。不要期望它现在就有用。
这是我想要它做到的事情
- 美观的测试报告,带有彩色字符串差异。(类似于[Mocha的](http://visionmedia.github.com/mocha/#string diffs))
- 上下文、before/after钩子等。
它将简单、Pythonic,并使用最小魔法。
关闭
pspec-0.0.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 69cd2cfdd465a88f1671938470865892fb6819e9b5263db7a7b68d554690f8a6 |
|
MD5 | 6acf79ecb965f0d41eb0fa2138026d8a |
|
BLAKE2b-256 | 2f7872170f164277726d533fcd76e699ff6c4254e023d3de4e6ae0d4e7f3a960 |