Skip to main content

should

https://img.shields.io/travis/Ralph-Wang/should.svg?style-flat-square https://img.shields.io/coveralls/Ralph-Wang/should.svg?style-flat-square

Bugs: https://github.com/Ralph-Wang/should/issues More Details: https://github.com/Ralph-Wang/should/blob/master/README.md

安装:

pip install should

使用方法:

from should import it

# 一般的断言
it(1).should.be.int
it({}).should.be.no.ok
it(2).should.be.equal(2)
it(10).should.be.no.equal(8)
it([1,2,3]).should.contain(3)

# lambda 版异常断言
it(lambda: int('abc')).should.throw(ValueError)
it(lambda: int('123')).should.no.throw(ValueError)
  • 更多例子请参考 tests

License

The MIT License

Change Log

v0.5.4

  • 增加 subclassof 接口

  • 添加 shouldnt 取反属性

v0.5.3

  • 增加 count 接口

  • 增加 same 接口, 判断是否为同一个对象

  • 拆分测试文件

v0.5.2

  • 小重构, 删除 _flag 属性

  • match/search 支持 list 和 dict. dict 只验证值

  • .contain 支持 contain(v1, v2, v3)

v0.5.1

  • 修复 #1, 解决自测问题

  • 结构化目录, 让代码清晰一点

  • 链式调用部分用元类改写

  • less/greater 添加 ‘below/above’ 别名

v0.5.0

  • 删除原 raises 接口, 不再支持 with should.raises 语法

  • raises 接口改为 throw 的等价接口

  • key 会改变链式调用. 后续值为键所对应的值

v0.4.8

  • fix throw 在 2.* 只能接受 str 的问题

  • 如 it(1).should.be.int 的类型断言, 不断言 property

  • proper 和 own_proper 增加别名 property 和 own_property

  • 增加 properties 和 own_properties. 对对象支持列表式断言

  • 增加 keys, 对字典支持列表式断言

v0.4.7

  • 添加 within 接口

  • should.py 文件中添加自文档

  • 添加 proper / own_proper 接口

v0.4.6

  • fix #2. match 不支持多行

  • 添加 search 接口, 与 match 等价, 但更贴近 Python re 的接口

v0.4.5

  • 增加 match 接口, 进行正则匹配断言

  • 增加 empty 属性, 直接判断容器或序列是否为空

  • 只有连接词, be, have 会出现在 Assertion Error 中

  • throw 接口支持断言 throw 信息

v0.4.4

  • 安装失败修复

v0.4.3

  • 类型断言如 it(1).should.be.int 支持所有内建类型

  • 添加 instanceof 断言, 支持其它类型或弱类型断言

  • 链式调用 ‘be’/’have’ 时, Error 信息正确显示 have 和 be

Metadata

Release files for should 0.5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for should 0.5.4
File Size Uploaded Provenance Actions
should-0.5.4.tar.gz 6.7 kB Without provenance Details for should-0.5.4.tar.gz

Release files / should-0.5.4.tar.gz

Download URL should-0.5.4.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
57a9befb07ba36334667a16007cc4a375fe07224c7bde58099604b3832fd5e3f
BLAKE2b-256 checksum
How to use checksums
28a5e4c48f30b4172bff8e603c4eb02f31f94bd8a0c063900e35bcfbdac53f1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for should 0.5.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page