expects
1.0.0
Expects是一個用於 Python 的富有表現力且可擴展的TDD/BDD 斷言函式庫。可以透過定義新的匹配器來擴展預期。
只需導入expect
可調用和內建匹配器並開始編寫測試斷言。
from expects import *
expect ([]). to ( be_empty )
expect ( False ). not_to ( be_true )
expect ({
'name' : 'Jack' ,
'email' : '[email protected]'
}). to ( have_key ( 'name' , match ( 'w+' )))
expect ( str ). to ( have_property ( 'split' ) & be_callable )
expect ( lambda : foo ). to ( raise_error ( NameError ))
expect ( 'Foo' ). to ( equal ( 'Bar' ) | equal ( 'Foo' ))
您可以使用 pip 或 easy_install 從 PyPI 安裝 Expects 的最新穩定版本。
$ pip install expects
您也可以從 Github 安裝最新的原始碼。
$ pip install -e git+git://github.com/jaimegildesagredo/expects.git#egg=expects
若要執行 Expects 規範,您應該安裝開發要求,然後執行 mamba。
$ pip install -r test-requirements.txt
$ mamba
請參閱更改。
請參閱第 3 方匹配器清單。