Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

should_dsl-2.1.2.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

should_dsl-2.1.2-py2.7.egg (21.4 kB view details)

Uploaded Source

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

Hashes for should_dsl-2.1.2.tar.gz
Algorithm Hash digest
SHA256 36f753d90fbdf84ef2b7a9e07813e3efac725376feb7a793549f3fff7a03232a
MD5 ac1cbaa66ac1c19b3f11e497a4a841f1
BLAKE2b-256 a3f0fa86e6065ca706dd0f9c4e2ab4d0dc0073641dd110615812a62d00ce4f50

See more details on using hashes here.

File details

Details for the file should_dsl-2.1.2-py2.7.egg.

File metadata

File hashes

Hashes for should_dsl-2.1.2-py2.7.egg
Algorithm Hash digest
SHA256 6fb6c77675024dd7334a5c66efb78211d42c68f10470e102784a8d46507fd8c1
MD5 39cc8d8ea96547116eacf2209839fcd9
BLAKE2b-256 0efd662d58c028bb806aa56e6ab6aa548438ccda669769dced820e0c06ee22f3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page