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

安装:

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)

# with 版异常断言, 不支持 no, 在 0.5 版本会被删除
with should.raises(ValueError):
    int('abc')

# lambda 版异常断言
it(lambda: int('abc')).should.throw(ValueError)
it(lambda: int('123')).should.no.throw(ValueError)

License

The MIT License

Change Log

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

Release files for should 0.4.7

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.4.7
File Size Uploaded
should-0.4.7.tar.gz 4.0 kB Details

Release files / should-0.4.7.tar.gz

Download URL should-0.4.7.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
adc4e24f5e38fe5deeae7e00813f610d4648bc8e59f166f85f8da964825c86b7
BLAKE2b-256 checksum
How to use checksums
0754102f714577260cb25fdb09eb82b27181a3806c922e9802587a2f305003fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.8

1 release file

This release

0.4.7 This release

1 release file

0.4.6

1 release file

0.4.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

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