Should assertions in Python as clear and readable as possible
Project description
The goal of Should-DSL is to write should expectations in Python as clear and readable as possible, using “almost” natural language (limited - sometimes - by the Python language constraints).
In order to use this DSL, you need to import should and should_not objects from should_dsl module.
For example:
>>> from should_dsl import should >>> 1 |should| equal_to(1) >>> 'should' |should| include('oul') >>> 3 |should| be_into([0, 1, 2]) Traceback (most recent call last): ... ShouldNotSatisfied: 3 is not into [0, 1, 2]
The equal_to matcher verifies object equality. If you want to ensure identity, you must use be as matcher:
>>> 2 |should| be(2)
A nice example of exceptions would be:
>>> def raise_zerodivisionerror(): ... return 1/0 >>> raise_zerodivisionerror |should| throw(ZeroDivisionError)
should has a negative version: should_not:
>>> from should_dsl import should_not >>> 2 |should_not| be_into([1, 3, 5]) >>> 'should' |should_not| include('oul') Traceback (most recent call last): ... ShouldNotSatisfied: 'should' does include 'oul'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file should_dsl-2.1.2.tar.gz
.
File metadata
- Download URL: should_dsl-2.1.2.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36f753d90fbdf84ef2b7a9e07813e3efac725376feb7a793549f3fff7a03232a |
|
MD5 | ac1cbaa66ac1c19b3f11e497a4a841f1 |
|
BLAKE2b-256 | a3f0fa86e6065ca706dd0f9c4e2ab4d0dc0073641dd110615812a62d00ce4f50 |
File details
Details for the file should_dsl-2.1.2-py2.7.egg
.
File metadata
- Download URL: should_dsl-2.1.2-py2.7.egg
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fb6c77675024dd7334a5c66efb78211d42c68f10470e102784a8d46507fd8c1 |
|
MD5 | 39cc8d8ea96547116eacf2209839fcd9 |
|
BLAKE2b-256 | 0efd662d58c028bb806aa56e6ab6aa548438ccda669769dced820e0c06ee22f3 |