示例工程 29-testing-pytest

29-testing-pytest/06-hypothesis-property/README.md

markdown · 0.7 KB

# 06 · hypothesis-property
 
**演示**:用 Hypothesis 的 `@given(st.text())` 生成大量文本,验证 UTF-8 编解码往返性质;失败时会自动缩小到最小反例。
**运行**:
 
```sh
uv run pytest examples/29-testing-pytest/06-hypothesis-property -q
```
 
**预期输出**(3.12.9,Hypothesis 版本可能影响进度条):
 
```text
...                                                                      [100%]
```
 
**依赖**:pytest + hypothesis(dev 组);缺失时测试 `importorskip` 跳过。
**注意**:属性测试适合「对所有输入都应成立」的不变量(往返、幂等、排序稳定性);不适合替代具体边界用例。